diff --git a/mock-identity-system/pom.xml b/mock-identity-system/pom.xml index d7d39db4..2f3a5e74 100644 --- a/mock-identity-system/pom.xml +++ b/mock-identity-system/pom.xml @@ -138,6 +138,41 @@ + + + com.networknt + json-schema-validator + 1.5.1 + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-databind + + + + + com.fasterxml.jackson.core + jackson-databind + 2.12.1 + + + com.fasterxml.jackson.core + jackson-core + 2.12.1 + + + com.fasterxml.jackson.core + jackson-annotations + 2.12.1 + diff --git a/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/controller/IdentityController.java b/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/controller/IdentityController.java index 1b49fa4c..6396bd60 100644 --- a/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/controller/IdentityController.java +++ b/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/controller/IdentityController.java @@ -8,8 +8,10 @@ import javax.validation.Valid; import io.mosip.esignet.mock.identitysystem.dto.*; +import io.mosip.esignet.mock.identitysystem.validator.IdentitySchema; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import io.mosip.esignet.mock.identitysystem.exception.MockIdentityException; @@ -21,6 +23,7 @@ @RestController @RequestMapping("/") +@Validated public class IdentityController { @Autowired @@ -29,7 +32,7 @@ public class IdentityController { @PostMapping(value = "identity", consumes = { MediaType.APPLICATION_JSON_VALUE }, produces = { MediaType.APPLICATION_JSON_VALUE }) public ResponseWrapper createIdentity - (@Valid @RequestBody RequestWrapper requestWrapper) throws MockIdentityException { + (@Valid @RequestBody @IdentitySchema(isCreate=true) RequestWrapper< IdentityData> requestWrapper) throws MockIdentityException { ResponseWrapper response = new ResponseWrapper(); IdentityStatus identityStatus = new IdentityStatus(); @@ -43,7 +46,7 @@ public class IdentityController { @PutMapping(value = "identity", consumes = { MediaType.APPLICATION_JSON_VALUE }, produces = { MediaType.APPLICATION_JSON_VALUE }) public ResponseWrapper updateIdentity - (@Valid @RequestBody RequestWrapper requestWrapper) throws MockIdentityException { + (@Valid @RequestBody @IdentitySchema(isCreate=false) RequestWrapper requestWrapper) throws MockIdentityException { ResponseWrapper response = new ResponseWrapper(); IdentityStatus identityStatus = new IdentityStatus(); diff --git a/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/util/ErrorConstants.java b/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/util/ErrorConstants.java index f903b905..910e0361 100644 --- a/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/util/ErrorConstants.java +++ b/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/util/ErrorConstants.java @@ -40,4 +40,5 @@ public class ErrorConstants { public static final String INVALID_TRUST_FRAMEWORK = "invalid_trust_framework"; public static final String INVALID_VERIFIED_DATE = "invalid_verified_date"; public static final String CLAIM_ALREADY_EXISTS="Claim already exists"; + public static final String INVALID_IDENTITY_DATA= "invalid_identity_data"; } diff --git a/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/validator/IdentitySchema.java b/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/validator/IdentitySchema.java new file mode 100644 index 00000000..5b4173fb --- /dev/null +++ b/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/validator/IdentitySchema.java @@ -0,0 +1,23 @@ +package io.mosip.esignet.mock.identitysystem.validator; + + +import io.mosip.esignet.mock.identitysystem.util.ErrorConstants; + +import javax.validation.Constraint; +import javax.validation.Payload; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.TYPE_USE, ElementType.FIELD, ElementType.PARAMETER}) +@Retention(RetentionPolicy.RUNTIME) +@Constraint(validatedBy = IdentitySchemaValidator.class) +public @interface IdentitySchema { + + String message() default ErrorConstants.INVALID_IDENTITY_DATA; + Class[] groups() default {}; + Class[] payload() default {}; + + boolean isCreate(); +} diff --git a/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/validator/IdentitySchemaValidator.java b/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/validator/IdentitySchemaValidator.java new file mode 100644 index 00000000..7e52f9ba --- /dev/null +++ b/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/validator/IdentitySchemaValidator.java @@ -0,0 +1,109 @@ +package io.mosip.esignet.mock.identitysystem.validator; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonSchemaFactory; +import com.networknt.schema.SpecVersion; +import com.networknt.schema.ValidationMessage; +import io.mosip.esignet.mock.identitysystem.dto.IdentityData; +import io.mosip.esignet.mock.identitysystem.dto.RequestWrapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.io.Resource; +import org.springframework.core.io.ResourceLoader; +import org.springframework.stereotype.Component; +import javax.validation.ConstraintValidator; +import javax.validation.ConstraintValidatorContext; +import java.io.IOException; +import java.io.InputStream; +import java.util.Set; + +@Component +@Slf4j +public class IdentitySchemaValidator implements ConstraintValidator { + + @Value("${mosip.mock.ida.identity.create.schema.url}") + private String createSchemaUrl; + + @Value("${mosip.mock.ida.identity.update.schema.url}") + private String updateSchemaUrl; + private boolean isCreate; + + private volatile JsonSchema cachedCreateSchema; + + private volatile JsonSchema cachedUpdateSchema; + + @Autowired + ObjectMapper objectMapper; + + @Autowired + ResourceLoader resourceLoader; + + @Override + public void initialize(IdentitySchema constraintAnnotation) { + this.isCreate = constraintAnnotation.isCreate(); + } + + @Override + public boolean isValid(Object object, ConstraintValidatorContext context) { + if (!(object instanceof RequestWrapper)) { + return false; + } + RequestWrapper wrapper= (RequestWrapper) object; + Object requestObject = wrapper.getRequest(); + if (!(requestObject instanceof IdentityData)) { + context.disableDefaultConstraintViolation(); + context.buildConstraintViolationWithTemplate("Invalid request object") + .addPropertyNode("request") + .addConstraintViolation(); + return false; + } + IdentityData identityData=(IdentityData) requestObject; + JsonNode identityJsonNode = objectMapper.valueToTree(identityData); + Set errors = isCreate + ? getCachedCreateSchema().validate(identityJsonNode) + : getCachedUpdateSchema().validate(identityJsonNode); + + if (!errors.isEmpty()) { + log.error("Validation failed for claims: {}", errors); + return false; + } + return true; + } + + private JsonSchema getCachedCreateSchema() { + if(cachedCreateSchema !=null ) return cachedCreateSchema; + synchronized (this) { + if (cachedCreateSchema == null) { + InputStream schemaResponse = getResource(createSchemaUrl); + JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V202012); + cachedCreateSchema = jsonSchemaFactory.getSchema(schemaResponse); + } + } + return cachedCreateSchema; + } + + private JsonSchema getCachedUpdateSchema() { + if(cachedUpdateSchema !=null ) return cachedUpdateSchema; + synchronized (this) { + if (cachedUpdateSchema == null) { + InputStream schemaResponse = getResource(updateSchemaUrl); + JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V202012); + cachedUpdateSchema = jsonSchemaFactory.getSchema(schemaResponse); + } + } + return cachedUpdateSchema; + } + + private InputStream getResource(String url) { + try{ + Resource resource = resourceLoader.getResource(url); + return resource.getInputStream(); + }catch (IOException e){ + log.error("Failed to parse data: {}", url, e); + } + throw new RuntimeException("invalid_configuration"); + } +} diff --git a/mock-identity-system/src/main/resources/application-default.properties b/mock-identity-system/src/main/resources/application-default.properties index 25080536..1d2288df 100644 --- a/mock-identity-system/src/main/resources/application-default.properties +++ b/mock-identity-system/src/main/resources/application-default.properties @@ -25,6 +25,11 @@ # mosip.api.internal.url # mosip.api.public.url +##-----------------------------------------Mock-identity-system properties---------------------------------------------- + +mosip.mock.ida.identity.create.schema.url=classpath:/mock-identity-create-schema.json +mosip.mock.ida.identity.update.schema.url=classpath:/mock-identity-update-schema.json + ##----------------------------------------- Database properties -------------------------------------------------------- mosip.mockidentitysystem.database.hostname=${database.host} mosip.mockidentitysystem.database.port=${database.port} diff --git a/mock-identity-system/src/main/resources/application-local.properties b/mock-identity-system/src/main/resources/application-local.properties index 499cdf19..bf63ee80 100644 --- a/mock-identity-system/src/main/resources/application-local.properties +++ b/mock-identity-system/src/main/resources/application-local.properties @@ -1,3 +1,9 @@ +##-----------------------------------------Mock-identity-system properties---------------------------------------------- + +mosip.mock.ida.identity.create.schema.url=classpath:/mock-identity-create-schema.json +mosip.mock.ida.identity.update.schema.url=classpath:/mock-identity-update-schema.json + + ##----------------------------------------- Database properties -------------------------------------------------------- spring.datasource.url=jdbc:postgresql://localhost:5455/mosip_mockidentitysystem?currentSchema=mockidentitysystem diff --git a/mock-identity-system/src/main/resources/mock-identity-create-schema.json b/mock-identity-system/src/main/resources/mock-identity-create-schema.json new file mode 100644 index 00000000..69aa1151 --- /dev/null +++ b/mock-identity-system/src/main/resources/mock-identity-create-schema.json @@ -0,0 +1,267 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "$defs": { + "langField": { + "type": "array", + "items": { + "type": "object", + "properties": { + "language": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "language", + "value" + ], + "additionalProperties": false + } + } + }, + "properties": { + "individualId": { + "type": "string", + "pattern": "^\\+855\\d{9}$" + }, + "fullName": { + "allOf": [ + { "$ref": "#/$defs/langField" }, + { + "items": { + "properties": { + "value": { + "pattern": "^(?:[a-zA-ZÀ-ÿ\\s]{1,40}|[ء-ي\\s-٩ٱ-ڿﹰ-\uFEFF\u0600-ۿ]{1,40})$" + } + } + } + } + ] + }, + "name": { + "allOf": [ + { "$ref": "#/$defs/langField" }, + { + "nullable": true + }, + { + "items": { + "properties": { + "value": { + "pattern": "^(?:[a-zA-ZÀ-ÿ\\s]{1,40}|[ء-ي\\s-٩ٱ-ڿﹰ-\uFEFF\u0600-ۿ]{1,40})$" + + } + } + } + } + ] + }, + "givenName": { + "allOf": [ + { "$ref": "#/$defs/langField" }, + { + "items": { + "properties": { + "value": { + "pattern": "^(?:[a-zA-ZÀ-ÿ\\s]{1,40}|[ء-ي\\s-٩ٱ-ڿﹰ-\uFEFF\u0600-ۿ]{1,40})$" + } + } + } + } + ] + }, + "familyName": { + "allOf": [ + { "$ref": "#/$defs/langField" }, + { + "items": { + "properties": { + "value": { + "pattern": "^(?:[a-zA-ZÀ-ÿ\\s]{1,40}|[ء-ي\\s-٩ٱ-ڿﹰ-\uFEFF\u0600-ۿ]{1,40})$" + } + } + } + } + ] + }, + "middleName": { + "allOf": [ + { "$ref": "#/$defs/langField" }, + { + "items": { + "properties": { + "value": { + "pattern": "^(?:[a-zA-ZÀ-ÿ\\s]{1,40}|[ء-ي\\s-٩ٱ-ڿﹰ-\uFEFF\u0600-ۿ]{1,40})$" + } + } + } + } + ] + }, + "nickName": { + "allOf": [ + { "$ref": "#/$defs/langField" }, + { + "items": { + "properties": { + "value": { + "pattern": "^(?:[a-zA-ZÀ-ÿ\\s]{1,40}|[ء-ي\\s-٩ٱ-ڿﹰ-\uFEFF\u0600-ۿ]{1,40})$" + } + } + } + } + ] + }, + "preferredUsername": { + "allOf": [ + { "$ref": "#/$defs/langField" }, + { + "items": { + "properties": { + "value": { + "pattern": "^(?:[a-zA-ZÀ-ÿ\\s]{1,40}|[ء-ي\\s-٩ٱ-ڿﹰ-\uFEFF\u0600-ۿ]{1,40})$" + } + } + } + } + ] + }, + "gender": { + "allOf": [ + { "$ref": "#/$defs/langField" }, + { + "items": { + "properties": { + "value": { + "pattern": "^(?:[a-zA-ZÀ-ÿ\\s]{1,20}|^[ء-ي\\s\\u0621-\\u064A\\u0660-\\u0669\\u0671-\\u06BF\\uFE70-\\uFEFF\\u0600-\\u06FFگچپژیلفقهمو ء-ي]{1,20}$)$" + } + } + } + } + ] + }, + "streetAddress": { + "allOf": [ + { "$ref": "#/$defs/langField" }, + { + "items": { + "properties": { + "value": { + "pattern": "^(?:[a-zA-ZÀ-ÿ0-9\\s.,°№-]{1,200}|[ء-ي\\s-٩ٱ-ڿﹰ-\uFEFF\u0600-ۿ0-9]{1,200})$" + + } + } + } + } + ] + }, + "locality": { + "allOf": [ + { "$ref": "#/$defs/langField" }, + { + "items": { + "properties": { + "value": { + "pattern": "^(?:[a-zA-ZÀ-ÿ0-9\\s.,°№-]{1,200}|[ء-ي\\s-٩ٱ-ڿﹰ-\uFEFF\u0600-ۿ0-9]{1,200})$" + } + } + } + } + ] + }, + "region": { + "allOf": [ + { "$ref": "#/$defs/langField" }, + { + "items": { + "properties": { + "value": { + "pattern": "^(?:[a-zA-ZÀ-ÿ0-9\\s.,°№-]{1,200}|[ء-ي\\s-٩ٱ-ڿﹰ-\uFEFF\u0600-ۿ0-9]{1,200})$" + } + } + } + } + ] + }, + "country": { + "allOf": [ + { "$ref": "#/$defs/langField" }, + { + "items": { + "properties": { + "value": { + "pattern": "^(?:[a-zA-ZÀ-ÿ\\s]{1,20}|^[ء-ي\\s\\u0621-\\u064A\\u0660-\\u0669\\u0671-\\u06BF\\uFE70-\\uFEFF\\u0600-\\u06FFگچپژیلفقهمو ء-ي]{1,20}$)$" + } + } + } + } + ] + }, + "pin": { + "type": "string", + "pattern": "\\S" + }, + "preferredLang": { + "type": "string" + }, + "dateOfBirth": { + "type": "string", + "pattern": "\\S" + }, + "postalCode": { + "type": "string", + "pattern": "\\S" + }, + "encodedPhoto": { + "type": "string" + }, + "email": { + "type": "string", + "pattern": "^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$" + }, + "phone": { + "type": "string", + "pattern": "\\S" + }, + "zoneInfo": { + "type": "string" + }, + "locale": { + "type": "string", + "pattern": "\\S" + }, + "password": { + "type": "string", + "pattern": "\\S" + } + }, + "required": [ + "individualId", + "fullName", + "name", + "givenName", + "familyName", + "middleName", + "nickName", + "preferredUsername", + "gender", + "streetAddress", + "locality", + "region", + "country", + "pin", + "preferredLang", + "dateOfBirth", + "postalCode", + "encodedPhoto", + "email", + "phone", + "zoneInfo", + "locale", + "password" + ], + "additionalProperties": false +} \ No newline at end of file diff --git a/mock-identity-system/src/main/resources/mock-identity-update-schema.json b/mock-identity-system/src/main/resources/mock-identity-update-schema.json new file mode 100644 index 00000000..4db8b953 --- /dev/null +++ b/mock-identity-system/src/main/resources/mock-identity-update-schema.json @@ -0,0 +1,254 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "$defs": { + "langField": { + "type": "array", + "items": { + "type": "object", + "properties": { + "language": { + "type": "string", + "nullable": true + }, + "value": { + "type": "string", + "nullable": true + } + }, + "required": [ + "language", + "value" + ], + "additionalProperties": false + }, + "nullable": true + } + }, + "properties": { + "individualId": { + "type": "string", + "pattern": "^\\+855\\d{9}$" + }, + "fullName": { + "allOf": [ + { "$ref": "#/$defs/langField" }, + { + "items": { + "properties": { + "value": { + "pattern": "^(?:[a-zA-ZÀ-ÿ\\s]{1,40}|[ء-ي\\s-٩ٱ-ڿﹰ-\uFEFF\u0600-ۿ]{1,40})$" + } + } + } + } + ] + }, + "name": { + "allOf": [ + { "$ref": "#/$defs/langField" }, + { + "items": { + "properties": { + "value": { + "pattern": "^(?:[a-zA-ZÀ-ÿ\\s]{1,40}|[ء-ي\\s-٩ٱ-ڿﹰ-\uFEFF\u0600-ۿ]{1,40})$" + + } + } + } + } + ] + }, + "givenName": { + "allOf": [ + { "$ref": "#/$defs/langField" }, + { + "items": { + "properties": { + "value": { + "pattern": "^(?:[a-zA-ZÀ-ÿ\\s]{1,40}|[ء-ي\\s-٩ٱ-ڿﹰ-\uFEFF\u0600-ۿ]{1,40})$" + } + } + } + } + ] + }, + "familyName": { + "allOf": [ + { "$ref": "#/$defs/langField" }, + { + "items": { + "properties": { + "value": { + "pattern": "^(?:[a-zA-ZÀ-ÿ\\s]{1,40}|[ء-ي\\s-٩ٱ-ڿﹰ-\uFEFF\u0600-ۿ]{1,40})$" + } + } + } + } + ] + }, + "middleName": { + "allOf": [ + { "$ref": "#/$defs/langField" }, + { + "items": { + "properties": { + "value": { + "pattern": "^(?:[a-zA-ZÀ-ÿ\\s]{1,40}|[ء-ي\\s-٩ٱ-ڿﹰ-\uFEFF\u0600-ۿ]{1,40})$" + } + } + } + } + ] + }, + "nickName": { + "allOf": [ + { "$ref": "#/$defs/langField" }, + { + "items": { + "properties": { + "value": { + "pattern": "^(?:[a-zA-ZÀ-ÿ\\s]{1,40}|[ء-ي\\s-٩ٱ-ڿﹰ-\uFEFF\u0600-ۿ]{1,40})$" + } + } + } + } + ] + }, + "preferredUsername": { + "allOf": [ + { "$ref": "#/$defs/langField" }, + { + "items": { + "properties": { + "value": { + "pattern": "^(?:[a-zA-ZÀ-ÿ\\s]{1,40}|[ء-ي\\s-٩ٱ-ڿﹰ-\uFEFF\u0600-ۿ]{1,40})$" + } + } + } + } + ] + }, + "gender": { + "allOf": [ + { "$ref": "#/$defs/langField" }, + { + "items": { + "properties": { + "value": { + "pattern": "^(?:[a-zA-ZÀ-ÿ\\s]{1,20}|^[ء-ي\\s\\u0621-\\u064A\\u0660-\\u0669\\u0671-\\u06BF\\uFE70-\\uFEFF\\u0600-\\u06FFگچپژیلفقهمو ء-ي]{1,20}$)$" + } + } + } + } + ] + }, + "streetAddress": { + "allOf": [ + { "$ref": "#/$defs/langField" }, + { + "items": { + "properties": { + "value": { + "pattern": "^(?:[a-zA-ZÀ-ÿ0-9\\s.,°№-]{1,200}|[ء-ي\\s-٩ٱ-ڿﹰ-\uFEFF\u0600-ۿ0-9]{1,200})$" + + } + } + } + } + ] + }, + "locality": { + "allOf": [ + { "$ref": "#/$defs/langField" }, + { + "items": { + "properties": { + "value": { + "pattern": "^(?:[a-zA-ZÀ-ÿ0-9\\s.,°№-]{1,200}|[ء-ي\\s-٩ٱ-ڿﹰ-\uFEFF\u0600-ۿ0-9]{1,200})$" + } + } + } + } + ] + }, + "region": { + "allOf": [ + { "$ref": "#/$defs/langField" }, + { + "items": { + "properties": { + "value": { + "pattern": "^(?:[a-zA-ZÀ-ÿ0-9\\s.,°№-]{1,200}|[ء-ي\\s-٩ٱ-ڿﹰ-\uFEFF\u0600-ۿ0-9]{1,200})$" + } + } + } + } + ] + }, + "country": { + "allOf": [ + { "$ref": "#/$defs/langField" }, + { + "items": { + "properties": { + "value": { + "pattern": "^(?:[a-zA-ZÀ-ÿ\\s]{1,20}|^[ء-ي\\s\\u0621-\\u064A\\u0660-\\u0669\\u0671-\\u06BF\\uFE70-\\uFEFF\\u0600-\\u06FFگچپژیلفقهمو ء-ي]{1,20}$)$" + } + } + } + } + ] + }, + "pin": { + "type": "string", + "pattern": "\\S", + "nullable": true + }, + "preferredLang": { + "type": "string", + "nullable": true + }, + "dateOfBirth": { + "type": "string", + "pattern": "\\S", + "nullable": true + }, + "postalCode": { + "type": "string", + "pattern": "\\S", + "nullable": true + }, + "encodedPhoto": { + "type": "string" + }, + "email": { + "type": "string", + "pattern": "^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$", + "nullable": true + }, + "phone": { + "type": "string", + "pattern": "\\S", + "nullable": true + }, + "zoneInfo": { + "type": "string", + "nullable": true + }, + "locale": { + "type": "string", + "pattern": "\\S", + "nullable": true + }, + "password": { + "type": "string", + "pattern": "\\S", + "nullable": true + } + }, + "required": [ + "individualId" + ], + "additionalProperties": false +} \ No newline at end of file diff --git a/mock-identity-system/src/test/java/io/mosip/esignet/mock/identitysystem/controller/IdentityControllerTest.java b/mock-identity-system/src/test/java/io/mosip/esignet/mock/identitysystem/controller/IdentityControllerTest.java index c1985195..3929e28d 100644 --- a/mock-identity-system/src/test/java/io/mosip/esignet/mock/identitysystem/controller/IdentityControllerTest.java +++ b/mock-identity-system/src/test/java/io/mosip/esignet/mock/identitysystem/controller/IdentityControllerTest.java @@ -55,12 +55,40 @@ public class IdentityControllerTest { @Before public void init() { identityRequest = new IdentityData(); - identityRequest.setIndividualId("123456789"); + identityRequest.setIndividualId("+855826741183"); identityRequest.setEmail("test@gmail.com"); + + List nameList=new ArrayList<>(); + LanguageValue engLangValue= new LanguageValue(); + engLangValue.setValue("Siddharth K Mansour"); + engLangValue.setLanguage("eng"); + LanguageValue arabicLangValue= new LanguageValue(); + arabicLangValue.setLanguage("ara"); + arabicLangValue.setValue("سيدارت ك منصور"); + nameList.add(engLangValue); + nameList.add(arabicLangValue); + identityRequest.setFullName(nameList); + identityRequest.setName(nameList); + identityRequest.setFamilyName(nameList); + identityRequest.setGivenName(nameList); + identityRequest.setPreferredUsername(nameList); + identityRequest.setNickName(nameList); + identityRequest.setPreferredUsername(nameList); + identityRequest.setMiddleName(nameList); + + LanguageValue mockLang = new LanguageValue(); + mockLang.setLanguage("eng"); + mockLang.setValue("mock"); + identityRequest.setGender(Arrays.asList(mockLang)); + identityRequest.setStreetAddress(Arrays.asList(mockLang)); + identityRequest.setLocality(Arrays.asList(mockLang)); + identityRequest.setRegion(Arrays.asList(mockLang)); + LanguageValue langValue = new LanguageValue(); langValue.setLanguage("eng"); langValue.setValue("ind"); identityRequest.setCountry(Arrays.asList(langValue)); + identityRequest.setDateOfBirth("20021990"); identityRequest.setEncodedPhoto("testencodedphoto"); identityRequest.setGender(Arrays.asList(langValue)); @@ -71,6 +99,10 @@ public void init() { identityRequest.setFullName(Arrays.asList(langValue)); identityRequest.setStreetAddress(Arrays.asList(langValue)); identityRequest.setPhone("9090909090"); + identityRequest.setPreferredLang("eng"); + identityRequest.setZoneInfo("local"); + identityRequest.setLocale("eng"); + identityRequest.setPassword("mock-password"); } @Test @@ -105,6 +137,7 @@ public void createIdentity_withInvalidIdentity_returnErrorResponse() throws Exce @Test public void getIdentity_withValidId_returnSuccessResponse() throws Exception { + identityRequest.setIndividualId("123456789"); Mockito.when(identityService.getIdentity(Mockito.anyString())).thenReturn(identityRequest); mockMvc.perform(get("/identity/{individualId}", "123456789")