11package com .yoti .api .client .docs .session .create ;
22
3- import static com .yoti .api .client .spi .remote .call .YotiConstants .DEFAULT_CHARSET ;
4-
53import static org .hamcrest .MatcherAssert .assertThat ;
64import static org .hamcrest .Matchers .contains ;
7- import static org .hamcrest .Matchers .equalTo ;
85import static org .hamcrest .Matchers .hasItems ;
96import static org .hamcrest .Matchers .hasSize ;
107import static org .hamcrest .Matchers .instanceOf ;
118import static org .hamcrest .Matchers .is ;
129import static org .hamcrest .Matchers .notNullValue ;
1310import static org .hamcrest .Matchers .nullValue ;
1411
15- import java .io .IOException ;
1612import java .time .ZonedDateTime ;
17- import java .util .HashMap ;
18- import java .util .Map ;
1913
2014import com .yoti .api .client .docs .session .create .check .RequestedDocumentAuthenticityCheck ;
2115import com .yoti .api .client .docs .session .create .check .RequestedLivenessCheck ;
2418import com .yoti .api .client .docs .session .create .resources .ResourceCreationContainer ;
2519import com .yoti .api .client .docs .session .create .task .RequestedIdDocTextExtractionTask ;
2620
27- import com .fasterxml .jackson .databind .JsonNode ;
28- import com .fasterxml .jackson .databind .ObjectMapper ;
29- import org .hamcrest .Matchers ;
3021import org .junit .Test ;
3122import org .junit .runner .RunWith ;
3223import org .mockito .Mock ;
@@ -51,14 +42,13 @@ public class SessionSpecTest {
5142 private static final String SOME_SDK_CONFIG_SUCCESS_URL = "https://yourdomain.com/some/success/endpoint" ;
5243 private static final String SOME_SDK_CONFIG_ERROR_URL = "https://yourdomain.com/some/error/endpoint" ;
5344
54- private static final ObjectMapper MAPPER = new ObjectMapper ();
55-
5645 @ Mock RequiredDocument requiredDocumentMock ;
5746 @ Mock IbvOptions ibvOptionsMock ;
5847 @ Mock ZonedDateTime sessionDeadlineMock ;
5948 @ Mock ResourceCreationContainer resourceCreationContainerMock ;
6049 @ Mock ImportTokenPayload importTokenMock ;
6150 @ Mock IdentityProfileRequirementsPayload identityProfileRequirementsPayloadMock ;
51+ @ Mock IdentityProfileSubjectPayload identityProfileSubjectPayloadMock ;
6252
6353 @ Test
6454 public void shouldBuildWithMinimalConfiguration () {
@@ -226,21 +216,12 @@ public void withIdentityProfile_shouldSetTheIdentityProfile() {
226216 }
227217
228218 @ 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 )
235222 .build ();
236223
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 ));
244225 }
245226
246227 @ Test
@@ -270,23 +251,4 @@ public void shouldBuildWithImportToken() {
270251 assertThat (sessionSpec .getImportToken (), is (importTokenMock ));
271252 }
272253
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-
292254}
0 commit comments