Skip to content

Commit

Permalink
MOSIP-24848-if-we-provide-invalid-schema-type-even-though-we-are-gett…
Browse files Browse the repository at this point in the history
…ing-attribute-names-list (mosip#719)

* MOSIP-24848 added validation on schemaType

* MOSIP-24848 added junit

* removed unused boolean variable

---------

Co-authored-by: Ritik Jain <[email protected]>
  • Loading branch information
2 people authored and Ritik Jain committed Oct 31, 2023
1 parent c4f906d commit fd0b94f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.mosip.resident.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

public enum UISchemaTypes {
Expand All @@ -28,12 +26,4 @@ public static Optional<UISchemaTypes> getUISchemaTypeFromString(String schemaTyp
}
return Optional.empty();
}

public static List<String> getUISchemaTypesList() {
List<String> uiSchemaValues = new ArrayList<>();
for (UISchemaTypes uiSchemaType : values()) {
uiSchemaValues.add(uiSchemaType.getFileIdentifier());
}
return uiSchemaValues;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;

import static io.mosip.resident.constant.RegistrationConstants.ID;
import static io.mosip.resident.constant.RegistrationConstants.MESSAGE_CODE;
Expand Down Expand Up @@ -973,8 +972,7 @@ public void validateSchemaType(String schemaType) {
if (uiSchemaTypeOptional.isEmpty()) {
audit.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.INPUT_INVALID,
ResidentConstants.SCHEMA_TYPE, "Validating schema type"));
throw new InvalidInputException(ResidentConstants.SCHEMA_TYPE + ". Valid values are "
+ UISchemaTypes.getUISchemaTypesList().stream().collect(Collectors.joining(", ")));
throw new InvalidInputException(ResidentConstants.SCHEMA_TYPE);
}
}

Expand Down

0 comments on commit fd0b94f

Please sign in to comment.