/** Property should have not null property key. */ @Test public void testNullPropertyKey() { BaseProjectProperty property = new BaseProjectProperty(project); try { property.setValue("value"); fail("PropertyKey shouldn't be null while calling setValue"); } catch (Exception e) { assertEquals(BaseProjectProperty.INVALID_PROPERTY_KEY_EXCEPTION, e.getMessage()); } try { property.getCascadingValue(); fail("PropertyKey shouldn't be null while calling getCascadingValue()"); } catch (Exception e) { assertEquals(BaseProjectProperty.INVALID_PROPERTY_KEY_EXCEPTION, e.getMessage()); } try { property.getValue(); fail("PropertyKey shouldn't be null while calling getValue()"); } catch (Exception e) { assertEquals(BaseProjectProperty.INVALID_PROPERTY_KEY_EXCEPTION, e.getMessage()); } property.setKey("key"); try { property.setValue("value"); property.getCascadingValue(); property.getValue(); } catch (Exception e) { fail("PropertyKey is valid"); } }
/** Verify {@link BaseProjectProperty#getCascadingValue()} method. */ @Test public void testGetCascadingValue() { String parentValue = "parentValue"; // If project doesn't have cascading project - default value is used as cascading value. assertEquals(property.getDefaultValue(), property.getCascadingValue()); project.setCascadingProject(parent); property = new BaseProjectProperty(project); property.setKey(propertyKey); // If project has cascading project and cascading value is not set - default value is used. assertEquals(property.getDefaultValue(), property.getCascadingValue()); BaseProjectProperty parentProperty = new BaseProjectProperty(parent); parentProperty.setKey(propertyKey); parentProperty.setValue(parentValue); parent.putProjectProperty(propertyKey, parentProperty); project.setCascadingProject(parent); property = new BaseProjectProperty(project); property.setKey(propertyKey); property.setValue(parentValue); // If project has cascading project and cascading value is set - property value will be used. assertEquals(parentProperty.getOriginalValue(), property.getCascadingValue()); }