This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
void whenATENANTUserCreatedMessageIsConsumed_UserUploadsRequiredDocuments_OperatorAcceptedThem_ShouldPublishDocumentUploadCompletedMessageDto() throws IOException { | |
testUserCreatedMessage = testUserCreatedMessage.toBuilder().userType(UserType.TENANT).build(); | |
final List<UUID> userDocumentUploadIds = givenUploadTasksOnUserCreation(); | |
givenUserSuccessFullyUploadedRequiredDocuments(userDocumentUploadIds); | |
givenOperatorAcceptedAllDocuments(userDocumentUploadIds); | |
final List<DocumentUploadCompletedMessageDto> documentUploadCompletedMessageDto = sqsTestHelper.retrieveDocumentUploadCompletedMessageDto(); | |
assertThat(documentUploadCompletedMessageDto).hasSize(1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
mockServer: | |
image: jamesdbloom/mockserver:mockserver-5.6.0 | |
ports: | |
- 1080 | |
environment: | |
- LOG_LEVEL=DEBUG # INFO | |
psql: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
ext { | |
springBootVersion = '2.1.4.RELEASE' | |
junitJupiterVersion = '5.3.2' | |
} | |
repositories { | |
maven { | |
url "https://plugins.gradle.org/m2/" | |
} | |
mavenCentral() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'docker-compose' | |
apply plugin: 'com.adarshr.test-logger' | |
// ====== integration tests config | |
task integrationTest(type: Test) { | |
// injecting thoes as fake secrets whic is just one way to stop aws from failing on application startup | |
environment "AWS_ACCESS_KEY_ID", "fake" | |
environment "AWS_SECRET_ACCESS_KEY", "fake" | |
useJUnitPlatform { | |
// tagging our tests is a new way of distinguishing between tests in Junit5 Jupiters engine. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring: | |
datasource: | |
url: jdbc:postgresql://${psql.host}:${psql.tcp.5432}/fake | |
username: postgres | |
password: fake | |
jpa: | |
flyway: | |
enabled: true | |
cloud: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private List<UUID> givenUploadTasksOnUserCreation() { | |
sqsTestHelper.givenAPublishedUserCreatedMessageAwaitedToBeConsumed(testUserCreatedMessage); | |
final UserDocumentUploadTaskDto[] response = httpRequestHelper.whenGetUploadTasksForUser(tenantUser(testUserCreatedMessage.getUserUuid())) | |
.then() | |
.statusCode(HttpStatus.OK.value()) | |
.extract().body().as(UserDocumentUploadTaskDto[].class); | |
final List<NotificationMessageDto> notificationMessageDtos = sqsTestHelper.retrieveNotificationMessages(); | |
assertThat(notificationMessageDtos).hasSize(1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void givenUserSuccessFullyUploadedRequiredDocuments(List<UUID> documentIds) throws IOException { | |
final UploadDocumentRequestDto uploadDocumentRequestDto = new UploadDocumentRequestDto( | |
Base64.getEncoder().encodeToString(ByteStreams.toByteArray(testDocumentPdf.getInputStream()))); | |
documentIds.forEach(documentId -> { | |
httpRequestHelper.whenPutUploadRequest(tenantUser(testUserCreatedMessage.getUserUuid()), documentId, uploadDocumentRequestDto) | |
.then() | |
.statusCode(HttpStatus.ACCEPTED.value()); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void givenOperatorAcceptedAllDocuments(List<UUID> userDocumentUploadIds) { | |
userDocumentUploadIds.forEach(documentId -> | |
httpRequestHelper.whenPutVerifyDocumentAccepted(operatorUser(UUID.randomUUID()), documentId).then() | |
.statusCode(HttpStatus.ACCEPTED.value())); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Bean(destroyMethod = "shutdown") | |
@Primary | |
public AmazonSQS getSqsClient(@Value("${localstack.host}") String sqsHost, @Value("${localstack.tcp.4576}") String port) { | |
final AmazonSQSAsync sqsClient = | |
AmazonSQSAsyncClientBuilder.standard() | |
.withEndpointConfiguration( | |
new AwsClientBuilder.EndpointConfiguration(sqsHost + ":" + port, "cn-north-1")) | |
.withClientConfiguration(new ClientConfiguration().withProtocol(Protocol.HTTP)).build(); | |
return sqsClient; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void givenResponseToGetUserInfo(UUID userUuid, UserInfoResponseDto userInfoResponseDto) { | |
mockServerClient.when(HttpRequest.request() | |
.withPath(String.format(USER_INFO_ENDPOINT, userUuid.toString())) | |
.withMethod(HttpMethod.GET.name()), Times.exactly(1)) | |
.respond(jsonResponse() | |
.withStatusCode(200) | |
.withBody(json(userInfoResponseDto))); | |
} | |
OlderNewer