Skip to content

Commit

Permalink
Add additional check for display true scenarios of mandatory properties
Browse files Browse the repository at this point in the history
  • Loading branch information
dulithsenanayake committed Jul 18, 2023
1 parent 7c1c1c7 commit bf5a79a
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2004,12 +2004,22 @@ public static boolean validateMandatoryProperties(org.json.simple.JSONArray cust
boolean isRequired = (boolean) property.get(APIConstants.CustomPropertyAttributes.REQUIRED);

if (isRequired) {
APIInfoAdditionalPropertiesMapDTO mapPropertyDisplay =
additionalPropertiesMap.get(propertyName + "__display");

Check warning on line 2008 in components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/PublisherCommonUtils.java

View check run for this annotation

Codecov / codecov/patch

components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/PublisherCommonUtils.java#L2007-L2008

Added lines #L2007 - L2008 were not covered by tests
APIInfoAdditionalPropertiesMapDTO mapProperty = additionalPropertiesMap.get(propertyName);
if (mapProperty == null) {
if (mapProperty == null && mapPropertyDisplay == null) {
return false;
}
String propertyValue = mapProperty.getValue();
if (propertyValue == null || propertyValue.isEmpty()) {
String propertyValue = "";
String propertyValueDisplay = "";

Check warning on line 2014 in components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/PublisherCommonUtils.java

View check run for this annotation

Codecov / codecov/patch

components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/PublisherCommonUtils.java#L2013-L2014

Added lines #L2013 - L2014 were not covered by tests
if (mapProperty != null) {
propertyValue = mapProperty.getValue();

Check warning on line 2016 in components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/PublisherCommonUtils.java

View check run for this annotation

Codecov / codecov/patch

components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/PublisherCommonUtils.java#L2016

Added line #L2016 was not covered by tests
}
if (mapPropertyDisplay != null) {
propertyValueDisplay = mapPropertyDisplay.getValue();

Check warning on line 2019 in components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/PublisherCommonUtils.java

View check run for this annotation

Codecov / codecov/patch

components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/PublisherCommonUtils.java#L2019

Added line #L2019 was not covered by tests
}
if ((propertyValue == null || propertyValue.isEmpty()) &&
(propertyValueDisplay == null || propertyValueDisplay.isEmpty())) {
return false;
}
}
Expand Down

0 comments on commit bf5a79a

Please sign in to comment.