summaryrefslogtreecommitdiffstats
path: root/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/PropertyRestUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/PropertyRestUtils.java')
-rw-r--r--asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/PropertyRestUtils.java122
1 files changed, 37 insertions, 85 deletions
diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/PropertyRestUtils.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/PropertyRestUtils.java
index 56ff5ec12b..a8661830ee 100644
--- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/PropertyRestUtils.java
+++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/PropertyRestUtils.java
@@ -46,70 +46,57 @@ public class PropertyRestUtils extends BaseRestUtils {
public static RestResponse createProperty(String resourceId, String body, User user) throws Exception {
Config config = Config.instance();
- String url = String.format(Urls.CREATE_PROPERTY, config.getCatalogBeHost(), config.getCatalogBePort(),
- resourceId);
+ String url = String.format(Urls.CREATE_PROPERTY, config.getCatalogBeHost(), config.getCatalogBePort(), resourceId);
return sendPost(url, body, user.getUserId(), acceptHeaderData);
}
- public static RestResponse updateProperty(String resourceId, String propertyId, String body, User user)
- throws Exception {
+ public static RestResponse updateProperty(String resourceId, String propertyId, String body, User user) throws Exception {
Config config = Config.instance();
- String url = String.format(Urls.UPDATE_PROPERTY, config.getCatalogBeHost(), config.getCatalogBePort(),
- resourceId, propertyId);
+ String url = String.format(Urls.UPDATE_PROPERTY, config.getCatalogBeHost(), config.getCatalogBePort(), resourceId, propertyId);
return sendPut(url, body, user.getUserId(), acceptHeaderData);
}
public static RestResponse getProperty(String resourceId, String propertyId, User user) throws Exception {
Config config = Config.instance();
- String url = String.format(Urls.GET_PROPERTY, config.getCatalogBeHost(), config.getCatalogBePort(), resourceId,
- propertyId);
+ String url = String.format(Urls.GET_PROPERTY, config.getCatalogBeHost(), config.getCatalogBePort(), resourceId, propertyId);
return sendGet(url, user.getUserId());
}
public static RestResponse deleteProperty(String resourceId, String propertyId, User user) throws Exception {
Config config = Config.instance();
- String url = String.format(Urls.DELETE_PROPERTY, config.getCatalogBeHost(), config.getCatalogBePort(),
- resourceId, propertyId);
+ String url = String.format(Urls.DELETE_PROPERTY, config.getCatalogBeHost(), config.getCatalogBePort(), resourceId, propertyId);
return sendDelete(url, user.getUserId());
}
- public static ComponentInstanceProperty getPropFromListByPropNameAndType(List<ComponentInstanceProperty> propList,
- String propNameToUpdate, String propTypeToUpdate) {
+ public static ComponentInstanceProperty getPropFromListByPropNameAndType(List<ComponentInstanceProperty> propList, String propNameToUpdate, String propTypeToUpdate) {
for (ComponentInstanceProperty componentInstanceProperty : propList) {
- if (componentInstanceProperty.getName().equals(propNameToUpdate)
- && componentInstanceProperty.getType().equals(propTypeToUpdate)) {
+ if (componentInstanceProperty.getName().equals(propNameToUpdate) && componentInstanceProperty.getType().equals(propTypeToUpdate)) {
return componentInstanceProperty;
}
}
return null;
}
- public static ComponentInstanceProperty getPropFromListByPropNameTypeAndPath(
- List<ComponentInstanceProperty> propList, String propNameToUpdate, String propTypeToUpdate,
- List<String> path) {
+ public static ComponentInstanceProperty getPropFromListByPropNameTypeAndPath(List<ComponentInstanceProperty> propList, String propNameToUpdate, String propTypeToUpdate, List<String> path) {
for (ComponentInstanceProperty componentInstanceProperty : propList) {
if (componentInstanceProperty.getPath() == null) {
return getPropFromListByPropNameAndType(propList, propNameToUpdate, propTypeToUpdate);
}
- if (componentInstanceProperty.getName().equals(propNameToUpdate)
- && componentInstanceProperty.getType().equals(propTypeToUpdate)
- && path.containsAll(componentInstanceProperty.getPath())) {
+ if (componentInstanceProperty.getName().equals(propNameToUpdate) && componentInstanceProperty.getType().equals(propTypeToUpdate) && path.containsAll(componentInstanceProperty.getPath())) {
return componentInstanceProperty;
}
}
return null;
}
- public static ComponentInstanceProperty getPropFromListByPropIdAndPath(List<ComponentInstanceProperty> propList,
- String propId, List<String> path) {
+ public static ComponentInstanceProperty getPropFromListByPropIdAndPath(List<ComponentInstanceProperty> propList, String propId, List<String> path) {
for (ComponentInstanceProperty componentInstanceProperty : propList) {
if (path != null) {
- if (componentInstanceProperty.getUniqueId().equals(propId)
- && componentInstanceProperty.getPath().equals(path)) {
+ if (componentInstanceProperty.getUniqueId().equals(propId) && componentInstanceProperty.getPath().equals(path)) {
return componentInstanceProperty;
}
} else {
@@ -121,12 +108,9 @@ public class PropertyRestUtils extends BaseRestUtils {
return null;
}
- public static void comparePropertyLists(List<ComponentInstanceProperty> expectedList,
- List<ComponentInstanceProperty> actualList, Boolean isUpdate) {
+ public static void comparePropertyLists(List<ComponentInstanceProperty> expectedList, List<ComponentInstanceProperty> actualList, Boolean isUpdate) {
- assertTrue(
- "list size are not equals, expected size is: " + expectedList.size() + " ,actual: " + actualList.size(),
- expectedList.size() == actualList.size());
+ assertTrue("list size are not equals, expected size is: " + expectedList.size() + " ,actual: " + actualList.size(), expectedList.size() == actualList.size());
Boolean flag = false;
for (ComponentInstanceProperty expectedcompInstProp : expectedList) {
for (ComponentInstanceProperty actualcompInstProp : actualList) {
@@ -138,47 +122,31 @@ public class PropertyRestUtils extends BaseRestUtils {
}
// System.out.println("expected: " + expectedList + ", actual: " +
// actualList);
- logger.debug("expected: {}, actual: {}", expectedList, actualList);
+ logger.debug("expected: {}, actual: {}",expectedList,actualList);
assertTrue("actual lists does not contain all uniqeIds", flag);
}
- public static Boolean comparePropertyObjects(ComponentInstanceProperty expectedCompInstProp,
- ComponentInstanceProperty actualCompInstProp, Boolean isUpdate) {
+ public static Boolean comparePropertyObjects(ComponentInstanceProperty expectedCompInstProp, ComponentInstanceProperty actualCompInstProp, Boolean isUpdate) {
String uniqueId = expectedCompInstProp.getUniqueId();
String type = expectedCompInstProp.getType();
String defaulValue = expectedCompInstProp.getDefaultValue();
- if (actualCompInstProp.getUniqueId().equals(uniqueId)
- && actualCompInstProp.getPath().equals(expectedCompInstProp.getPath())) {
- assertTrue("expected type is: " + type + " ,actual: " + actualCompInstProp.getType(),
- actualCompInstProp.getType().equals(type));
+ if (actualCompInstProp.getUniqueId().equals(uniqueId) && actualCompInstProp.getPath().equals(expectedCompInstProp.getPath())) {
+ assertTrue("expected type is: " + type + " ,actual: " + actualCompInstProp.getType(), actualCompInstProp.getType().equals(type));
if (defaulValue == null) {
- assertTrue(
- "expected defaulValue is: " + defaulValue + " ,actual: " + actualCompInstProp.getDefaultValue(),
- actualCompInstProp.getDefaultValue() == defaulValue);
+ assertTrue("expected defaulValue is: " + defaulValue + " ,actual: " + actualCompInstProp.getDefaultValue(), actualCompInstProp.getDefaultValue() == defaulValue);
} else {
- assertTrue(
- "expected defaulValue is: " + defaulValue + " ,actual: " + actualCompInstProp.getDefaultValue(),
- actualCompInstProp.getDefaultValue().equals(defaulValue));
+ assertTrue("expected defaulValue is: " + defaulValue + " ,actual: " + actualCompInstProp.getDefaultValue(), actualCompInstProp.getDefaultValue().equals(defaulValue));
}
if (isUpdate) {
- assertTrue(
- "actual [Value] parameter " + actualCompInstProp.getName()
- + "should equal to expected [Value]: " + actualCompInstProp.getValue() + " ,Value: "
- + actualCompInstProp.getValue(),
+ assertTrue("actual [Value] parameter " + actualCompInstProp.getName() + "should equal to expected [Value]: " + actualCompInstProp.getValue() + " ,Value: " + actualCompInstProp.getValue(),
actualCompInstProp.getValue().equals(expectedCompInstProp.getValue()));
assertNotNull("valueId is null", actualCompInstProp.getValueUniqueUid());
} else {
if (defaulValue == null) {
- assertTrue(
- "actual [Value] parameter " + actualCompInstProp.getName()
- + "should equal to expected [defaultValue]: " + actualCompInstProp.getValue()
- + " ,defaultValue: " + actualCompInstProp.getDefaultValue(),
+ assertTrue("actual [Value] parameter " + actualCompInstProp.getName() + "should equal to expected [defaultValue]: " + actualCompInstProp.getValue() + " ,defaultValue: " + actualCompInstProp.getDefaultValue(),
actualCompInstProp.getValue() == expectedCompInstProp.getDefaultValue());
} else {
- assertTrue(
- "actual [Value] parameter " + actualCompInstProp.getName()
- + "should equal to expected [defaultValue]: " + actualCompInstProp.getValue()
- + " ,defaultValue: " + actualCompInstProp.getDefaultValue(),
+ assertTrue("actual [Value] parameter " + actualCompInstProp.getName() + "should equal to expected [defaultValue]: " + actualCompInstProp.getValue() + " ,defaultValue: " + actualCompInstProp.getDefaultValue(),
actualCompInstProp.getValue().equals(expectedCompInstProp.getDefaultValue()));
}
assertNull("valueId is not null", actualCompInstProp.getValueUniqueUid());
@@ -188,16 +156,14 @@ public class PropertyRestUtils extends BaseRestUtils {
return false;
}
- public static List<ComponentInstanceProperty> addResourcePropertiesToList(Resource resource,
- List<ComponentInstanceProperty> listToFill) {
+ public static List<ComponentInstanceProperty> addResourcePropertiesToList(Resource resource, List<ComponentInstanceProperty> listToFill) {
for (PropertyDefinition prop : resource.getProperties()) {
listToFill.add(new ComponentInstanceProperty(prop, null, null));
}
return listToFill;
}
- public static List<ComponentInstanceProperty> addComponentInstPropertiesToList(Component component,
- List<ComponentInstanceProperty> listToFill, String componentId) {
+ public static List<ComponentInstanceProperty> addComponentInstPropertiesToList(Component component, List<ComponentInstanceProperty> listToFill, String componentId) {
if (componentId != null) {
List<ComponentInstanceProperty> list = component.getComponentInstancesProperties().get(componentId);
@@ -209,13 +175,10 @@ public class PropertyRestUtils extends BaseRestUtils {
listToFill.add(componentInstanceProperty);
}
} else {
- Map<String, List<ComponentInstanceProperty>> componentInstancesProperties = component
- .getComponentInstancesProperties();
- for (Map.Entry<String, List<ComponentInstanceProperty>> componentInstanceProperties : componentInstancesProperties
- .entrySet()) {
+ Map<String, List<ComponentInstanceProperty>> componentInstancesProperties = component.getComponentInstancesProperties();
+ for (Map.Entry<String, List<ComponentInstanceProperty>> componentInstanceProperties : componentInstancesProperties.entrySet()) {
for (ComponentInstanceProperty prop : componentInstanceProperties.getValue()) {
- ComponentInstanceProperty componentInstanceProperty = new ComponentInstanceProperty(prop, null,
- null);
+ ComponentInstanceProperty componentInstanceProperty = new ComponentInstanceProperty(prop, null, null);
componentInstanceProperty.setPath(prop.getPath());
componentInstanceProperty.setValueUniqueUid(prop.getValueUniqueUid());
componentInstanceProperty.setValue(prop.getValue());
@@ -232,22 +195,18 @@ public class PropertyRestUtils extends BaseRestUtils {
return listToFill;
}
- public static ComponentInstanceProperty getCompPropInstListByInstIdAndPropName(Component component,
- ComponentInstance componentInstanceDetails, String name, String type) {
- List<ComponentInstanceProperty> propList = component.getComponentInstancesProperties()
- .get(componentInstanceDetails.getUniqueId());
+ public static ComponentInstanceProperty getCompPropInstListByInstIdAndPropName(Component component, ComponentInstance componentInstanceDetails, String name, String type) {
+ List<ComponentInstanceProperty> propList = component.getComponentInstancesProperties().get(componentInstanceDetails.getUniqueId());
if (propList != null) {
return getPropFromListByPropNameAndType(propList, name, type);
}
return null;
}
- private static void updatePropertyListWithPathParameter(Resource resource, List<String> path,
- List<ComponentInstanceProperty> expectedPropertyList) {
+ private static void updatePropertyListWithPathParameter(Resource resource, List<String> path, List<ComponentInstanceProperty> expectedPropertyList) {
List<PropertyDefinition> propertyList = resource.getProperties();
for (PropertyDefinition propertyDefinition : propertyList) {
- ComponentInstanceProperty propDetailsToRemove = PropertyRestUtils.getPropFromListByPropNameAndType(
- expectedPropertyList, propertyDefinition.getName(), propertyDefinition.getType());
+ ComponentInstanceProperty propDetailsToRemove = PropertyRestUtils.getPropFromListByPropNameAndType(expectedPropertyList, propertyDefinition.getName(), propertyDefinition.getType());
ComponentInstanceProperty propDetailsToAdd = propDetailsToRemove;
propDetailsToAdd.setPath(path);
expectedPropertyList.remove(propDetailsToRemove);
@@ -255,24 +214,19 @@ public class PropertyRestUtils extends BaseRestUtils {
}
}
- private static void updatePropertyListWithPathParameterOnCompInst(Service service, List<String> path,
- List<ComponentInstanceProperty> expectedPropertyList) {
+ private static void updatePropertyListWithPathParameterOnCompInst(Service service, List<String> path, List<ComponentInstanceProperty> expectedPropertyList) {
List<ComponentInstanceProperty> servicePropertyList = new ArrayList<>();
- servicePropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, servicePropertyList,
- path.get(0));
+ servicePropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, servicePropertyList, path.get(0));
for (ComponentInstanceProperty serviceCompInstProperty : servicePropertyList) {
- ComponentInstanceProperty propDetailsToRemove = PropertyRestUtils.getPropFromListByPropNameTypeAndPath(
- expectedPropertyList, serviceCompInstProperty.getName(), serviceCompInstProperty.getType(),
- serviceCompInstProperty.getPath());
+ ComponentInstanceProperty propDetailsToRemove = PropertyRestUtils.getPropFromListByPropNameTypeAndPath(expectedPropertyList, serviceCompInstProperty.getName(), serviceCompInstProperty.getType(), serviceCompInstProperty.getPath());
ComponentInstanceProperty propDetailsToAdd = propDetailsToRemove;
List<String> tempPathList = new ArrayList<String>();
for (String tempPath : path) {
tempPathList.add(tempPath);
}
// path parameter can not contain the same service unique ID twice
- if (propDetailsToAdd.getPath() != null
- && !propDetailsToAdd.getPath().get(0).contains(service.getUniqueId())) {
+ if (propDetailsToAdd.getPath() != null && !propDetailsToAdd.getPath().get(0).contains(service.getUniqueId())) {
if (!propDetailsToAdd.getPath().containsAll(tempPathList)) {
tempPathList.addAll(propDetailsToAdd.getPath());
}
@@ -283,8 +237,7 @@ public class PropertyRestUtils extends BaseRestUtils {
}
}
- public static void updatePropertyListWithPathOnResource(ComponentInstance componentInstDetails, Resource resource,
- List<ComponentInstanceProperty> list, Component container) {
+ public static void updatePropertyListWithPathOnResource(ComponentInstance componentInstDetails, Resource resource, List<ComponentInstanceProperty> list, Component container) {
List<String> path = new ArrayList<>();
if (container != null) {
List<ComponentInstance> componentInstances = container.getComponentInstances();
@@ -301,8 +254,7 @@ public class PropertyRestUtils extends BaseRestUtils {
updatePropertyListWithPathParameter(resource, path, list);
}
- public static void updatePropertyListWithPathOnComponentInstance(ComponentInstance componentInstDetails,
- Service service, List<ComponentInstanceProperty> list) {
+ public static void updatePropertyListWithPathOnComponentInstance(ComponentInstance componentInstDetails, Service service, List<ComponentInstanceProperty> list) {
List<String> path = new ArrayList<>();
path.add(componentInstDetails.getUniqueId());
updatePropertyListWithPathParameterOnCompInst(service, path, list);