private static boolean isValueEquals( final AbstractField<?> field, final Object orginalValue, final Object currentValue) { if (Set.class.equals(field.getType())) { return CollectionUtils.isEqualCollection( CollectionUtils.emptyIfNull((Collection<?>) orginalValue), CollectionUtils.emptyIfNull((Collection<?>) currentValue)); } if (String.class.equals(field.getType())) { return Objects.equals( Strings.emptyToNull((String) orginalValue), Strings.emptyToNull((String) currentValue)); } return Objects.equals(orginalValue, currentValue); }
@Test public void testLoadMembershipFromProp() { Member actual_master = ((MasterMembership) this.master_membership).self(); List<Member> actual_slaves = ((MasterMembership) this.master_membership).getSlaves(); Member expected_master = Member.parseMember("127.0.0.1@8000;master0@1099").get(); Member expected_slave1 = Member.parseMember("127.0.0.1@5000;slave01@1099").get(); Member expected_slave2 = Member.parseMember("127.0.0.1@6000;slave02@1099").get(); List<Member> expected_slaves = new ArrayList<>(); expected_slaves.add(expected_slave1); expected_slaves.add(expected_slave2); assertEquals( "Fails to load the master which should be " + expected_master, expected_master, actual_master); assertTrue( "Fails to load the slaves.", CollectionUtils.isEqualCollection(expected_slaves, actual_slaves)); }