Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies {
implementation 'software.amazon.awssdk:sts'
implementation 'javax.inject:javax.inject:1'
testImplementation 'com.amazonaws:DynamoDBLocal:2.2.1'
testImplementation 'org.awaitility:awaitility:4.2.0'
}

configurations {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
import java.util.Optional;
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

import static org.awaitility.Awaitility.await;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
Expand Down Expand Up @@ -265,8 +267,16 @@ void tryAcquireAvailablePartition_gets_first_unassigned_partition() {
objectUnderTest.tryCreatePartitionItem(sourceIdentifier,
unassignedPartitionKey3, SourcePartitionStatus.UNASSIGNED, 1L, partitionProgressState, false);

final Optional<SourcePartitionStoreItem> maybeAcquired =
objectUnderTest.tryAcquireAvailablePartition(sourceIdentifier, ownerId, Duration.ofSeconds(20));
// Wait for partition to be available in DynamoDB Local before attempting to acquire
final Optional<SourcePartitionStoreItem>[] maybeAcquiredHolder = new Optional[]{Optional.empty()};
await().atMost(5, TimeUnit.SECONDS)
.pollInterval(100, TimeUnit.MILLISECONDS)
.untilAsserted(() -> {
maybeAcquiredHolder[0] = objectUnderTest.tryAcquireAvailablePartition(sourceIdentifier, ownerId, Duration.ofSeconds(20));
assertThat(maybeAcquiredHolder[0].isPresent(), equalTo(true));
});

final Optional<SourcePartitionStoreItem> maybeAcquired = maybeAcquiredHolder[0];

assertThat(maybeAcquired, notNullValue());
assertThat(maybeAcquired.isPresent(), equalTo(true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void testValidateConfig() {

@Test
void testValidateConfigBasic() {
when(confluenceSourceConfig.getAccountUrl()).thenReturn("https://test.com");
when(confluenceSourceConfig.getAccountUrl()).thenReturn("https://somedomain.atlassian.net");
when(confluenceSourceConfig.getAuthType()).thenReturn(BASIC);
when(confluenceSourceConfig.getAuthenticationConfig()).thenReturn(authenticationConfig);
when(authenticationConfig.getBasicConfig()).thenReturn(basicConfig);
Expand All @@ -137,7 +137,7 @@ void testValidateConfigBasic() {

@Test
void testValidateConfigOauth2() {
when(confluenceSourceConfig.getAccountUrl()).thenReturn("https://test.com");
when(confluenceSourceConfig.getAccountUrl()).thenReturn("https://somedomain.atlassian.net");
when(confluenceSourceConfig.getAuthType()).thenReturn(OAUTH2);
when(confluenceSourceConfig.getAuthenticationConfig()).thenReturn(authenticationConfig);
when(authenticationConfig.getOauth2Config()).thenReturn(oauth2Config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void testGetProjectNameFilter() {
void testValidateConfig() {
assertThrows(RuntimeException.class, () -> JiraConfigHelper.validateConfig(jiraSourceConfig));

when(jiraSourceConfig.getAccountUrl()).thenReturn("https://test.com");
when(jiraSourceConfig.getAccountUrl()).thenReturn("https://somedomain.atlassian.net");
assertThrows(RuntimeException.class, () -> JiraConfigHelper.validateConfig(jiraSourceConfig));

when(jiraSourceConfig.getAuthType()).thenReturn("fakeType");
Expand All @@ -135,7 +135,7 @@ void testValidateConfig() {

@Test
void testValidateConfigBasic() {
when(jiraSourceConfig.getAccountUrl()).thenReturn("https://test.com");
when(jiraSourceConfig.getAccountUrl()).thenReturn("https://somedomain.atlassian.net");
when(jiraSourceConfig.getAuthType()).thenReturn(BASIC);
when(jiraSourceConfig.getAuthenticationConfig()).thenReturn(authenticationConfig);
when(authenticationConfig.getBasicConfig()).thenReturn(basicConfig);
Expand All @@ -154,7 +154,7 @@ void testValidateConfigBasic() {

@Test
void testValidateConfigOauth2() {
when(jiraSourceConfig.getAccountUrl()).thenReturn("https://test.com");
when(jiraSourceConfig.getAccountUrl()).thenReturn("https://somedomain.atlassian.net");
when(jiraSourceConfig.getAuthType()).thenReturn(OAUTH2);
when(jiraSourceConfig.getAuthenticationConfig()).thenReturn(authenticationConfig);
when(authenticationConfig.getOauth2Config()).thenReturn(oauth2Config);
Expand Down
Loading