/** 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");
    }
  }
 /** Verify {@link BaseProjectProperty#getOriginalValue()} method. */
 @Test
 public void testGetOriginalValue() {
   assertNull(property.getOriginalValue());
   Object value = new Object();
   property.setKey(propertyKey);
   property.setValue(value);
   assertEquals(value, property.getOriginalValue());
   property.setValue(null);
   assertNull(property.getOriginalValue());
 }
 /** Verify {@link BaseProjectProperty#resetValue()} method. */
 @Test
 public void testResetValue() {
   property.setKey(propertyKey);
   property.setValue(new Object());
   property.setOverridden(true);
   assertNotNull(property.getOriginalValue());
   assertTrue(property.isOverridden());
   property.resetValue();
   assertNull(property.getOriginalValue());
   assertFalse(property.isOverridden());
 }
  /** 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());
  }
  /** Verify {@link BaseProjectProperty#setValue(Object)} method. */
  @Test
  public void testSetValue() {
    BaseProjectProperty property = new BaseProjectProperty(project);
    property.setKey(propertyKey);
    property.setValue(null);
    // If project doesn't have cascading - default boolean value is used for propertyOverridden flag
    assertFalse(property.isOverridden());
    assertNull(property.getOriginalValue());

    Object value = 12345;
    property.setValue(value);
    // If project doesn't have cascading - default boolean value is used for propertyOverridden flag
    assertFalse(property.isOverridden());
    assertEquals(value, property.getOriginalValue());

    String parentValue = "equalValue";
    BaseProjectProperty parentProperty = new BaseProjectProperty(parent);
    parentProperty.setKey(propertyKey);
    parentProperty.setValue(parentValue);
    parent.putProjectProperty(propertyKey, parentProperty);
    project.setCascadingProject(parent);

    // If value set to null, need to check whether default value is equals to cascading
    property.setValue(null);
    assertTrue(property.isOverridden());
    String overriddenValue = "newValue";
    property.setValue(overriddenValue);
    assertTrue(property.isOverridden());

    // Check whether current value is not null, after setting equal-to-cascading value current will
    // be null
    assertNotNull(property.getOriginalValue());
    assertTrue(property.isOverridden());
    property.setValue(parentValue);
    // Reset current property to null
    assertNull(property.getOriginalValue());
    // Cascading value is equal to current - reset flag to false.
    assertFalse(property.isOverridden());
  }