-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
30710:Creation of SeqSumissionOpenApi (#220)
- Loading branch information
Showing
2 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
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
54 changes: 54 additions & 0 deletions
54
src/test/java/ca/gc/aafc/seqdb/api/openapi/SeqSubmissionOpenApiIT.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package ca.gc.aafc.seqdb.api.openapi; | ||
|
||
import ca.gc.aafc.dina.testsupport.BaseRestAssuredTest; | ||
import ca.gc.aafc.dina.testsupport.PostgresTestContainerInitializer; | ||
import ca.gc.aafc.dina.testsupport.jsonapi.JsonAPIRelationship; | ||
import ca.gc.aafc.dina.testsupport.jsonapi.JsonAPITestHelper; | ||
import ca.gc.aafc.dina.testsupport.specs.OpenAPI3Assertions; | ||
import ca.gc.aafc.dina.testsupport.specs.ValidationRestrictionOptions; | ||
import ca.gc.aafc.seqdb.api.SeqdbApiLauncher; | ||
import ca.gc.aafc.seqdb.api.dto.SeqBatchDto; | ||
import ca.gc.aafc.seqdb.api.dto.SeqSubmissionDto; | ||
import ca.gc.aafc.seqdb.api.testsupport.fixtures.*; | ||
import lombok.SneakyThrows; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.TestPropertySource; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
@SpringBootTest( | ||
classes = SeqdbApiLauncher.class, | ||
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT | ||
) | ||
@TestPropertySource(properties = "spring.config.additional-location=classpath:application-test.yml") | ||
@ContextConfiguration(initializers = {PostgresTestContainerInitializer.class}) | ||
public class SeqSubmissionOpenApiIT extends BaseRestAssuredTest{ | ||
protected SeqSubmissionOpenApiIT(){super("/api");} | ||
@SneakyThrows | ||
@Test | ||
void seqSubmission_SpecValid() { | ||
|
||
SeqBatchDto seqBatchDto = SeqBatchTestFixture.newSeqBatch(); | ||
seqBatchDto.setExperimenters(null); | ||
String seqBatchDtoUuid = JsonAPITestHelper.extractId( | ||
sendPost(SeqBatchDto.TYPENAME, | ||
JsonAPITestHelper.toJsonAPIMap(SeqBatchDto.TYPENAME, JsonAPITestHelper.toAttributeMap(seqBatchDto)))); | ||
|
||
|
||
SeqSubmissionDto seqSubmissionDto = SeqSubmissionTestFixture.newSeqSubmission(); | ||
seqSubmissionDto.setSubmittedBy(null); | ||
|
||
OpenAPI3Assertions.assertRemoteSchema(OpenAPIConstants.SEQDB_API_SPECS_URL, "SeqSubmission", | ||
sendPost(SeqSubmissionDto.TYPENAME, JsonAPITestHelper.toJsonAPIMap(SeqSubmissionDto.TYPENAME, JsonAPITestHelper.toAttributeMap(seqSubmissionDto), | ||
JsonAPITestHelper.toRelationshipMap( | ||
List.of(JsonAPIRelationship.of("seqBatch", SeqBatchDto.TYPENAME, seqBatchDtoUuid), | ||
JsonAPIRelationship.of("submittedBy", "person", UUID.randomUUID().toString()) | ||
)), | ||
null) | ||
).extract().asString(), | ||
ValidationRestrictionOptions.builder().build()); | ||
} | ||
} |