1
1
package ca .gc .aafc .objectstore .api .openapi ;
2
2
3
- import java .net .MalformedURLException ;
4
- import java .net .URISyntaxException ;
5
- import java .net .URL ;
6
3
import java .time .OffsetDateTime ;
4
+ import java .util .List ;
7
5
import java .util .UUID ;
8
- import java .util .Map ;
9
6
10
7
import javax .inject .Inject ;
11
8
import javax .persistence .criteria .CriteriaBuilder ;
12
9
import javax .persistence .criteria .CriteriaDelete ;
13
10
import javax .persistence .criteria .Root ;
14
11
import javax .transaction .Transactional ;
15
12
16
- import org . apache . http . client . utils . URIBuilder ;
13
+ import ca . gc . aafc . dina . testsupport . jsonapi . JsonAPIRelationship ;
17
14
import org .junit .jupiter .api .AfterEach ;
18
15
import org .junit .jupiter .api .BeforeEach ;
19
16
import org .junit .jupiter .api .Test ;
@@ -85,17 +82,18 @@ public void setup() {
85
82
86
83
ObjectStoreMetadataDto osMetadata = buildObjectStoreMetadataDto ();
87
84
88
- metadataUuid = sendPost ("metadata" , JsonAPITestHelper .toJsonAPIMap ("metadata" , JsonAPITestHelper .toAttributeMap (osMetadata ), null , null )).extract ().body ().jsonPath ().get ("data.id" );
85
+ metadataUuid = JsonAPITestHelper .extractId (sendPost ("metadata" ,
86
+ JsonAPITestHelper .toJsonAPIMap ("metadata" , JsonAPITestHelper .toAttributeMap (osMetadata ), null , null )));
89
87
90
88
DerivativeDto derivative = buildDerivativeDto (objectUpload_generatedFrom .getFileIdentifier ());
91
89
92
- derivativeUuid = sendPost (RESOURCE_UNDER_TEST , JsonAPITestHelper .toJsonAPIMap (
93
- RESOURCE_UNDER_TEST ,
94
- JsonAPITestHelper .toAttributeMap (derivative ),
95
- Map . of (
96
- "acDerivedFrom" , getRelationshipType ( "metadata" , metadataUuid )),
97
- null )). extract (). body (). jsonPath (). get ( "data.id" );
98
-
90
+ derivativeUuid = JsonAPITestHelper . extractId ( sendPost (RESOURCE_UNDER_TEST , JsonAPITestHelper .toJsonAPIMap (
91
+ DerivativeDto . TYPENAME ,
92
+ JsonAPITestHelper .toAttributeMap (derivative ),
93
+ JsonAPITestHelper . toRelationshipMap (
94
+ JsonAPIRelationship . of ( "acDerivedFrom" , "metadata" , metadataUuid )
95
+ ),
96
+ null )));
99
97
}
100
98
101
99
/**
@@ -116,20 +114,15 @@ public void tearDown() {
116
114
void derivative_SpecValid () {
117
115
DerivativeDto derivativeDto = buildDerivativeDto (objectUpload .getFileIdentifier ());
118
116
OpenAPI3Assertions .assertRemoteSchema (OpenAPIConstants .OBJECT_STORE_API_SPECS_URL , SCHEMA_NAME ,
117
+
119
118
sendPost (RESOURCE_UNDER_TEST , JsonAPITestHelper .toJsonAPIMap (
120
119
RESOURCE_UNDER_TEST ,
121
120
JsonAPITestHelper .toAttributeMap (derivativeDto ),
122
- Map .of (
123
- "acDerivedFrom" , getRelationshipType ("metadata" , metadataUuid ),
124
- "generatedFromDerivative" , getRelationshipType ("derivative" , derivativeUuid )),
125
- null ))
126
- .extract ().asString ());
127
- }
128
-
129
- private Map <String , Object > getRelationshipType (String type , String uuid ) {
130
- return Map .of ("data" , Map .of (
131
- "id" , uuid ,
132
- "type" , type ));
121
+ JsonAPITestHelper .toRelationshipMap (
122
+ List .of (
123
+ JsonAPIRelationship .of ("acDerivedFrom" , "metadata" , metadataUuid ),
124
+ JsonAPIRelationship .of ("generatedFromDerivative" , "derivative" , derivativeUuid ))),
125
+ null )).extract ().asString ());
133
126
}
134
127
135
128
private DerivativeDto buildDerivativeDto (UUID fileIdentifier ) {
0 commit comments