1
1
package com .yoti .api .client .docs .session .create ;
2
2
3
- import static com .yoti .api .client .spi .remote .call .YotiConstants .DEFAULT_CHARSET ;
4
-
5
3
import static org .hamcrest .MatcherAssert .assertThat ;
6
4
import static org .hamcrest .Matchers .contains ;
7
- import static org .hamcrest .Matchers .equalTo ;
8
5
import static org .hamcrest .Matchers .hasItems ;
9
6
import static org .hamcrest .Matchers .hasSize ;
10
7
import static org .hamcrest .Matchers .instanceOf ;
11
8
import static org .hamcrest .Matchers .is ;
12
9
import static org .hamcrest .Matchers .notNullValue ;
13
10
import static org .hamcrest .Matchers .nullValue ;
14
11
15
- import java .io .IOException ;
16
12
import java .time .ZonedDateTime ;
17
- import java .util .HashMap ;
18
- import java .util .Map ;
19
13
20
14
import com .yoti .api .client .docs .session .create .check .RequestedDocumentAuthenticityCheck ;
21
15
import com .yoti .api .client .docs .session .create .check .RequestedLivenessCheck ;
24
18
import com .yoti .api .client .docs .session .create .resources .ResourceCreationContainer ;
25
19
import com .yoti .api .client .docs .session .create .task .RequestedIdDocTextExtractionTask ;
26
20
27
- import com .fasterxml .jackson .databind .JsonNode ;
28
- import com .fasterxml .jackson .databind .ObjectMapper ;
29
- import org .hamcrest .Matchers ;
30
21
import org .junit .Test ;
31
22
import org .junit .runner .RunWith ;
32
23
import org .mockito .Mock ;
@@ -51,14 +42,13 @@ public class SessionSpecTest {
51
42
private static final String SOME_SDK_CONFIG_SUCCESS_URL = "https://yourdomain.com/some/success/endpoint" ;
52
43
private static final String SOME_SDK_CONFIG_ERROR_URL = "https://yourdomain.com/some/error/endpoint" ;
53
44
54
- private static final ObjectMapper MAPPER = new ObjectMapper ();
55
-
56
45
@ Mock RequiredDocument requiredDocumentMock ;
57
46
@ Mock IbvOptions ibvOptionsMock ;
58
47
@ Mock ZonedDateTime sessionDeadlineMock ;
59
48
@ Mock ResourceCreationContainer resourceCreationContainerMock ;
60
49
@ Mock ImportTokenPayload importTokenMock ;
61
50
@ Mock IdentityProfileRequirementsPayload identityProfileRequirementsPayloadMock ;
51
+ @ Mock IdentityProfileSubjectPayload identityProfileSubjectPayloadMock ;
62
52
63
53
@ Test
64
54
public void shouldBuildWithMinimalConfiguration () {
@@ -226,21 +216,12 @@ public void withIdentityProfile_shouldSetTheIdentityProfile() {
226
216
}
227
217
228
218
@ Test
229
- public void shouldBuildWithSubject () throws IOException {
230
- Map <String , Object > subject = new HashMap <>();
231
- subject .put (SubjectProperty .SUBJECT_ID , "A_SUBJECT_ID" );
232
-
233
- SessionSpec session = SessionSpec .builder ()
234
- .withSubject (subject )
219
+ public void withSubject_shouldSetTheSubject () {
220
+ SessionSpec result = SessionSpec .builder ()
221
+ .withSubject (identityProfileSubjectPayloadMock )
235
222
.build ();
236
223
237
- ObjectMapper mapper = new ObjectMapper ();
238
-
239
- JsonNode json = mapper .readTree (
240
- mapper .writeValueAsString (session .getSubject ()).getBytes (DEFAULT_CHARSET )
241
- );
242
-
243
- assertThat (json .get ("subject_id" ).asText (), is (Matchers .equalTo (subject .get (SubjectProperty .SUBJECT_ID ))));
224
+ assertThat (result .getSubject (), is (identityProfileSubjectPayloadMock ));
244
225
}
245
226
246
227
@ Test
@@ -270,23 +251,4 @@ public void shouldBuildWithImportToken() {
270
251
assertThat (sessionSpec .getImportToken (), is (importTokenMock ));
271
252
}
272
253
273
- private static final class IdentityProperty {
274
-
275
- private static final String TYPE = "type" ;
276
- private static final String SCHEME = "scheme" ;
277
- private static final String OBJECTIVE = "objective" ;
278
- private static final String TRUST_FRAMEWORK = "trust_framework" ;
279
-
280
- private IdentityProperty () { }
281
-
282
- }
283
-
284
- private static final class SubjectProperty {
285
-
286
- private static final String SUBJECT_ID = "subject_id" ;
287
-
288
- private SubjectProperty () {}
289
-
290
- }
291
-
292
254
}
0 commit comments