Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a bug where the PropertyValue equals always returned false #328

Merged
merged 1 commit into from
Aug 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@
*
* @author eeverman
*/
public class PropertyValue<T> {
public class PropertyValue<T> {

private final Property<T> property;
private final T value;

/**
* Overrides standard equals to return true if the Property is the same
* class instance and the values are equal.
*
* @param obj
* @return true or false based on same Property instance and equal value.
*/
@Override
public boolean equals(Object obj) {
boolean basicPropsEq = false;
Expand All @@ -28,7 +35,7 @@ public boolean equals(Object obj) {

}

return false;
return basicPropsEq;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package org.yarnandtail.andhow;

import org.junit.Test;

import static org.junit.Assert.*;
import static org.yarnandtail.andhow.SimpleParams.*;

/**
*
* @author ericeverman
*/
public class PropertyValueTest {

public PropertyValueTest() {
}

/**
* Test of equals method, of class PropertyValue.
*/
@Test
public void testEquals() {

//Try some string properties
PropertyValue spv1 = new PropertyValue(STR_BOB, "abc");
PropertyValue spv2 = new PropertyValue(STR_BOB, "abc");
PropertyValue spv3 = new PropertyValue(STR_BOB, "def");
PropertyValue spv4 = new PropertyValue(STR_BOB, null);
PropertyValue spv5 = new PropertyValue(STR_NULL, "abc");
PropertyValue spv6 = new PropertyValue(STR_NULL, "abc");
PropertyValue spv7 = new PropertyValue(STR_NULL, "def");
PropertyValue spv8 = new PropertyValue(STR_NULL, null);

//
assertTrue(spv1.equals(spv1));
assertTrue(spv1.equals(spv2));
assertFalse(spv1.equals(spv3));
assertFalse(spv1.equals(spv4));
assertFalse(spv1.equals(spv5));
assertFalse(spv1.equals(spv6));
assertFalse(spv1.equals(spv7));
assertFalse(spv1.equals(spv8));
//
assertTrue(spv2.equals(spv1));
assertTrue(spv2.equals(spv2));
assertFalse(spv2.equals(spv3));
assertFalse(spv2.equals(spv4));
assertFalse(spv2.equals(spv5));
assertFalse(spv2.equals(spv6));
assertFalse(spv2.equals(spv7));
assertFalse(spv2.equals(spv8));
//
assertFalse(spv3.equals(spv1));
assertFalse(spv3.equals(spv2));
assertTrue(spv3.equals(spv3));
assertFalse(spv3.equals(spv4));
assertFalse(spv3.equals(spv5));
assertFalse(spv3.equals(spv6));
assertFalse(spv3.equals(spv7));
assertFalse(spv3.equals(spv8));
//
assertFalse(spv5.equals(spv1));
assertFalse(spv5.equals(spv2));
assertFalse(spv5.equals(spv3));
assertFalse(spv5.equals(spv4));
assertTrue(spv5.equals(spv5));
assertTrue(spv5.equals(spv6));
assertFalse(spv5.equals(spv7));
assertFalse(spv5.equals(spv8));
//
assertFalse(spv1.equals(null));
}

/**
* Test of hashCode method, of class PropertyValue.
*/
@Test
public void testHashCode() {
}

/**
* Test of getProperty method, of class PropertyValue.
*/
@Test
public void testGetProperty() {
}

/**
* Test of getValue method, of class PropertyValue.
*/
@Test
public void testGetValue() {
}

}