@Test public void testcheckProperty() throws Exception { Class<UpdateConnection> class1 = UpdateConnection.class; Method method = class1.getDeclaredMethod("checkProperty",new Class[]{List.class,List.class}); method.setAccessible(true); when(property.getPropertyName()).thenReturn(propertyName); when(propertyDefinition.getPropertyName()).thenReturn(propertyName2); when(property.getPropertyName().toString()).thenReturn(new String("propertyname")); Assert.assertEquals(method.invoke(updateConnection, propertyList, propertyDefinitionList), "This type of propertypropertyname has not been defined."); }
private String checkProperty(List<Property> connectionProperty, List<PropertyDefinition> propertyDefinitionList ){ String errorInfo = null; for (Property property : connectionProperty) { Boolean properyHasDefine = false; if (errorInfo != null) { break; } else { for (PropertyDefinition propertyDefinition : propertyDefinitionList) { if (property.getPropertyName().equals(propertyDefinition.getPropertyName())) { properyHasDefine = true; PropertyValues propertyValues = property.getPropertyValues(); PropertyDefinition.PropertyValueType propertyValueType = propertyDefinition.getPropertyValueType(); if (propertyValues != null && propertyValueType != null) { if (propertyDefinition.getIsReadOnly()!=null && PropertyDefinition.IsReadOnly.ReadOnly == propertyDefinition.getIsReadOnly()) { if (propertyDefinition.getIsRequired().getIntValue() == 1) { errorInfo = "The property value type of " + property.getPropertyName().toString() + " is read only."; break; } } else { if (propertyValueType.getIntValue() == 0 && !(propertyValues.getIntValue() == null && propertyValues.getStringValue() != null && propertyValues.getRangeValue() == null)) { errorInfo = "The property value type of " + property.getPropertyName().toString() + " should be string."; break; } if (propertyValueType.getIntValue() == 1 && !(propertyValues.getIntValue() != null && propertyValues.getStringValue() == null && propertyValues.getRangeValue() == null)) { errorInfo = "The property value type of" + property.getPropertyName().toString() + " should be integer."; break; } if (propertyValueType.getIntValue() == 2 && !(propertyValues.getIntValue() == null && propertyValues.getStringValue() == null && propertyValues.getRangeValue() != null)) { errorInfo = "The property value type of" + property.getPropertyName().toString() + " should be range."; break; } } } } } if (!properyHasDefine) { errorInfo = "This type of property" + property.getPropertyName().toString() + " has not been defined."; } } } if (errorInfo == null) { Boolean requiredProperty = false; for (PropertyDefinition propertyDefinition : propertyDefinitionList) { if (propertyDefinition.getIsRequired()!=null) { if (propertyDefinition.getIsRequired().getIntValue() == 0) { for (Property property : connectionProperty) { if (property.getPropertyName().equals(propertyDefinition.getPropertyName())) { requiredProperty = true; } } if (!requiredProperty) { errorInfo = "The required property" + propertyDefinition.getPropertyName().toString() + "is not included in the intent."; } } } } } return errorInfo; }
UpdateConnection { private String checkProperty(List<Property> connectionProperty, List<PropertyDefinition> propertyDefinitionList ){ String errorInfo = null; for (Property property : connectionProperty) { Boolean properyHasDefine = false; if (errorInfo != null) { break; } else { for (PropertyDefinition propertyDefinition : propertyDefinitionList) { if (property.getPropertyName().equals(propertyDefinition.getPropertyName())) { properyHasDefine = true; PropertyValues propertyValues = property.getPropertyValues(); PropertyDefinition.PropertyValueType propertyValueType = propertyDefinition.getPropertyValueType(); if (propertyValues != null && propertyValueType != null) { if (propertyDefinition.getIsReadOnly()!=null && PropertyDefinition.IsReadOnly.ReadOnly == propertyDefinition.getIsReadOnly()) { if (propertyDefinition.getIsRequired().getIntValue() == 1) { errorInfo = "The property value type of " + property.getPropertyName().toString() + " is read only."; break; } } else { if (propertyValueType.getIntValue() == 0 && !(propertyValues.getIntValue() == null && propertyValues.getStringValue() != null && propertyValues.getRangeValue() == null)) { errorInfo = "The property value type of " + property.getPropertyName().toString() + " should be string."; break; } if (propertyValueType.getIntValue() == 1 && !(propertyValues.getIntValue() != null && propertyValues.getStringValue() == null && propertyValues.getRangeValue() == null)) { errorInfo = "The property value type of" + property.getPropertyName().toString() + " should be integer."; break; } if (propertyValueType.getIntValue() == 2 && !(propertyValues.getIntValue() == null && propertyValues.getStringValue() == null && propertyValues.getRangeValue() != null)) { errorInfo = "The property value type of" + property.getPropertyName().toString() + " should be range."; break; } } } } } if (!properyHasDefine) { errorInfo = "This type of property" + property.getPropertyName().toString() + " has not been defined."; } } } if (errorInfo == null) { Boolean requiredProperty = false; for (PropertyDefinition propertyDefinition : propertyDefinitionList) { if (propertyDefinition.getIsRequired()!=null) { if (propertyDefinition.getIsRequired().getIntValue() == 0) { for (Property property : connectionProperty) { if (property.getPropertyName().equals(propertyDefinition.getPropertyName())) { requiredProperty = true; } } if (!requiredProperty) { errorInfo = "The required property" + propertyDefinition.getPropertyName().toString() + "is not included in the intent."; } } } } } return errorInfo; } }
UpdateConnection { private String checkProperty(List<Property> connectionProperty, List<PropertyDefinition> propertyDefinitionList ){ String errorInfo = null; for (Property property : connectionProperty) { Boolean properyHasDefine = false; if (errorInfo != null) { break; } else { for (PropertyDefinition propertyDefinition : propertyDefinitionList) { if (property.getPropertyName().equals(propertyDefinition.getPropertyName())) { properyHasDefine = true; PropertyValues propertyValues = property.getPropertyValues(); PropertyDefinition.PropertyValueType propertyValueType = propertyDefinition.getPropertyValueType(); if (propertyValues != null && propertyValueType != null) { if (propertyDefinition.getIsReadOnly()!=null && PropertyDefinition.IsReadOnly.ReadOnly == propertyDefinition.getIsReadOnly()) { if (propertyDefinition.getIsRequired().getIntValue() == 1) { errorInfo = "The property value type of " + property.getPropertyName().toString() + " is read only."; break; } } else { if (propertyValueType.getIntValue() == 0 && !(propertyValues.getIntValue() == null && propertyValues.getStringValue() != null && propertyValues.getRangeValue() == null)) { errorInfo = "The property value type of " + property.getPropertyName().toString() + " should be string."; break; } if (propertyValueType.getIntValue() == 1 && !(propertyValues.getIntValue() != null && propertyValues.getStringValue() == null && propertyValues.getRangeValue() == null)) { errorInfo = "The property value type of" + property.getPropertyName().toString() + " should be integer."; break; } if (propertyValueType.getIntValue() == 2 && !(propertyValues.getIntValue() == null && propertyValues.getStringValue() == null && propertyValues.getRangeValue() != null)) { errorInfo = "The property value type of" + property.getPropertyName().toString() + " should be range."; break; } } } } } if (!properyHasDefine) { errorInfo = "This type of property" + property.getPropertyName().toString() + " has not been defined."; } } } if (errorInfo == null) { Boolean requiredProperty = false; for (PropertyDefinition propertyDefinition : propertyDefinitionList) { if (propertyDefinition.getIsRequired()!=null) { if (propertyDefinition.getIsRequired().getIntValue() == 0) { for (Property property : connectionProperty) { if (property.getPropertyName().equals(propertyDefinition.getPropertyName())) { requiredProperty = true; } } if (!requiredProperty) { errorInfo = "The required property" + propertyDefinition.getPropertyName().toString() + "is not included in the intent."; } } } } } return errorInfo; } UpdateConnection(DataBroker dataBroker, TenantManage tenantManage); }
UpdateConnection { private String checkProperty(List<Property> connectionProperty, List<PropertyDefinition> propertyDefinitionList ){ String errorInfo = null; for (Property property : connectionProperty) { Boolean properyHasDefine = false; if (errorInfo != null) { break; } else { for (PropertyDefinition propertyDefinition : propertyDefinitionList) { if (property.getPropertyName().equals(propertyDefinition.getPropertyName())) { properyHasDefine = true; PropertyValues propertyValues = property.getPropertyValues(); PropertyDefinition.PropertyValueType propertyValueType = propertyDefinition.getPropertyValueType(); if (propertyValues != null && propertyValueType != null) { if (propertyDefinition.getIsReadOnly()!=null && PropertyDefinition.IsReadOnly.ReadOnly == propertyDefinition.getIsReadOnly()) { if (propertyDefinition.getIsRequired().getIntValue() == 1) { errorInfo = "The property value type of " + property.getPropertyName().toString() + " is read only."; break; } } else { if (propertyValueType.getIntValue() == 0 && !(propertyValues.getIntValue() == null && propertyValues.getStringValue() != null && propertyValues.getRangeValue() == null)) { errorInfo = "The property value type of " + property.getPropertyName().toString() + " should be string."; break; } if (propertyValueType.getIntValue() == 1 && !(propertyValues.getIntValue() != null && propertyValues.getStringValue() == null && propertyValues.getRangeValue() == null)) { errorInfo = "The property value type of" + property.getPropertyName().toString() + " should be integer."; break; } if (propertyValueType.getIntValue() == 2 && !(propertyValues.getIntValue() == null && propertyValues.getStringValue() == null && propertyValues.getRangeValue() != null)) { errorInfo = "The property value type of" + property.getPropertyName().toString() + " should be range."; break; } } } } } if (!properyHasDefine) { errorInfo = "This type of property" + property.getPropertyName().toString() + " has not been defined."; } } } if (errorInfo == null) { Boolean requiredProperty = false; for (PropertyDefinition propertyDefinition : propertyDefinitionList) { if (propertyDefinition.getIsRequired()!=null) { if (propertyDefinition.getIsRequired().getIntValue() == 0) { for (Property property : connectionProperty) { if (property.getPropertyName().equals(propertyDefinition.getPropertyName())) { requiredProperty = true; } } if (!requiredProperty) { errorInfo = "The required property" + propertyDefinition.getPropertyName().toString() + "is not included in the intent."; } } } } } return errorInfo; } UpdateConnection(DataBroker dataBroker, TenantManage tenantManage); String ConnectionHandling(UserId userId, Connection connection); }
UpdateConnection { private String checkProperty(List<Property> connectionProperty, List<PropertyDefinition> propertyDefinitionList ){ String errorInfo = null; for (Property property : connectionProperty) { Boolean properyHasDefine = false; if (errorInfo != null) { break; } else { for (PropertyDefinition propertyDefinition : propertyDefinitionList) { if (property.getPropertyName().equals(propertyDefinition.getPropertyName())) { properyHasDefine = true; PropertyValues propertyValues = property.getPropertyValues(); PropertyDefinition.PropertyValueType propertyValueType = propertyDefinition.getPropertyValueType(); if (propertyValues != null && propertyValueType != null) { if (propertyDefinition.getIsReadOnly()!=null && PropertyDefinition.IsReadOnly.ReadOnly == propertyDefinition.getIsReadOnly()) { if (propertyDefinition.getIsRequired().getIntValue() == 1) { errorInfo = "The property value type of " + property.getPropertyName().toString() + " is read only."; break; } } else { if (propertyValueType.getIntValue() == 0 && !(propertyValues.getIntValue() == null && propertyValues.getStringValue() != null && propertyValues.getRangeValue() == null)) { errorInfo = "The property value type of " + property.getPropertyName().toString() + " should be string."; break; } if (propertyValueType.getIntValue() == 1 && !(propertyValues.getIntValue() != null && propertyValues.getStringValue() == null && propertyValues.getRangeValue() == null)) { errorInfo = "The property value type of" + property.getPropertyName().toString() + " should be integer."; break; } if (propertyValueType.getIntValue() == 2 && !(propertyValues.getIntValue() == null && propertyValues.getStringValue() == null && propertyValues.getRangeValue() != null)) { errorInfo = "The property value type of" + property.getPropertyName().toString() + " should be range."; break; } } } } } if (!properyHasDefine) { errorInfo = "This type of property" + property.getPropertyName().toString() + " has not been defined."; } } } if (errorInfo == null) { Boolean requiredProperty = false; for (PropertyDefinition propertyDefinition : propertyDefinitionList) { if (propertyDefinition.getIsRequired()!=null) { if (propertyDefinition.getIsRequired().getIntValue() == 0) { for (Property property : connectionProperty) { if (property.getPropertyName().equals(propertyDefinition.getPropertyName())) { requiredProperty = true; } } if (!requiredProperty) { errorInfo = "The required property" + propertyDefinition.getPropertyName().toString() + "is not included in the intent."; } } } } } return errorInfo; } UpdateConnection(DataBroker dataBroker, TenantManage tenantManage); String ConnectionHandling(UserId userId, Connection connection);  }