/** Verify {@link BaseProjectProperty#getValue()} method. */ @Test public void testGetValue() { Integer propertyValue = 10; property.setValue(propertyValue); // if value is not null - return it assertEquals(propertyValue, property.getValue()); property.setValue(null); assertNull(property.getValue()); BaseProjectProperty parentProperty = new BaseProjectProperty(parent); parentProperty.setKey(propertyKey); parentProperty.setValue(propertyValue); parent.putProjectProperty(propertyKey, parentProperty); project.setCascadingProject(parent); property = new BaseProjectProperty(project); property.setKey(propertyKey); // if current value is null and is not overridden value, take from cascading assertNull(property.getOriginalValue()); assertEquals(propertyValue, property.getValue()); property.setOverridden(true); // Property is overridden - return current value even if it is null. assertNull(property.getOriginalValue()); assertNull(property.getValue()); }
/** 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"); } }