Skip to content

Commit

Permalink
Formatting and naming cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
esocode committed Jan 20, 2024
1 parent f4c11cc commit 5f64282
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 47 deletions.
11 changes: 6 additions & 5 deletions src/main/java/de/esoco/lib/collection/CollectionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -899,17 +899,18 @@ public static Map<Object, Object> parseMap(String... entries) {
* Any
* whitespace characters surrounding the map entries will be removed.
*
* @param entries The entry string to be parsed
* @param cSeparator The separator character between key value pairs (will
* be used in a call to <code>Pattern.split()</code>).
* @param entries The entry string to be parsed
* @param separator The separator character between key value pairs
* (will be
* used in a call to <code>Pattern.split()</code>).
* @return A new map containing the parsed entries
* @throws IllegalArgumentException If the parsing of a map entry fails
* @see #parseMap(String...)
* @see Pattern#split(java.lang.CharSequence)
*/
public static Map<Object, Object> parseMap(String entries,
char cSeparator) {
return parseMap(entries.split("" + cSeparator));
char separator) {
return parseMap(entries.split("" + separator));
}

/**
Expand Down
17 changes: 8 additions & 9 deletions src/test/java/de/esoco/lib/json/JsonBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ public void testAppendRelatable() {

json.appendRelatable(createTestRelatable(), null, true);

assertEquals(
"{\"NAME\":\"TEST\",\"INFO\":\"JSON\",\"PORT\":12345," +
assertEquals("{\"NAME\":\"TEST\",\"INFO\":\"JSON\",\"PORT\":12345," +
"\"MODIFIED\":true," +
"\"PARENT\":{\"NAME\":\"PARENT\",\"INFO\":\"JSON_OBJECT\"}," +
"\"CHILDREN\":[{\"NAME\":\"CHILD1\"},{\"NAME\":\"CHILD2\"}]}",
Expand Down Expand Up @@ -128,8 +127,8 @@ public void testAppendRelatableWithSerializedTypes() {
}

/**
* Test of {@link JsonBuilder#append(org.obrel.core.Relation, boolean,
* boolean)}
* Test of
* {@link JsonBuilder#append(org.obrel.core.Relation, boolean, boolean)}
*/
@Test
public void testAppendRelation() {
Expand Down Expand Up @@ -233,21 +232,21 @@ public void testAppendValue() {
protected Relatable createTestRelatable() {
RelatedObject testObj = new RelatedObject();
RelatedObject parent = new RelatedObject();
RelatedObject aChild1 = new RelatedObject();
RelatedObject aChild2 = new RelatedObject();
RelatedObject child1 = new RelatedObject();
RelatedObject child2 = new RelatedObject();

parent.set(StandardTypes.NAME, "PARENT");
parent.set(StandardTypes.INFO, "JSON_OBJECT");

aChild1.set(StandardTypes.NAME, "CHILD1");
aChild2.set(StandardTypes.NAME, "CHILD2");
child1.set(StandardTypes.NAME, "CHILD1");
child2.set(StandardTypes.NAME, "CHILD2");

testObj.set(StandardTypes.NAME, "TEST");
testObj.set(StandardTypes.INFO, "JSON");
testObj.set(StandardTypes.PORT, 12345);
testObj.set(MetaTypes.MODIFIED);
testObj.set(StandardTypes.PARENT, parent);
testObj.set(StandardTypes.CHILDREN, Arrays.asList(aChild1, aChild2));
testObj.set(StandardTypes.CHILDREN, Arrays.asList(child1, child2));

return testObj;
}
Expand Down
50 changes: 25 additions & 25 deletions src/test/java/org/obrel/core/RelationListenerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,26 @@ public class RelationListenerTest {
*/
@Test
public void testObjectRelationListener() {
RelatedObject aTest1 = new RelatedObject();
RelatedObject aTest2 = new RelatedObject();
RelatedObject test1 = new RelatedObject();
RelatedObject test2 = new RelatedObject();

TestListener<?> listener = new TestListener<>();

aTest1.get(ListenerTypes.RELATION_LISTENERS).add(listener);
test1.get(ListenerTypes.RELATION_LISTENERS).add(listener);

aTest1.set(NAME, "TEST1");
aTest2.set(NAME, "TEST2");
test1.set(NAME, "TEST1");
test2.set(NAME, "TEST2");

assertEquals("TEST1", relationTarget);

aTest1.set(NAME, "TEST1A");
test1.set(NAME, "TEST1A");
assertEquals("TEST1A", relationTarget);

aTest1.deleteRelation(NAME);
test1.deleteRelation(NAME);
assertNull(relationTarget);

aTest1.get(ListenerTypes.RELATION_LISTENERS).remove(listener);
assertTrue(aTest1
test1.get(ListenerTypes.RELATION_LISTENERS).remove(listener);
assertTrue(test1
.get(ListenerTypes.RELATION_LISTENERS)
.getEventHandlerCount() == 0);
}
Expand Down Expand Up @@ -99,23 +99,23 @@ public void testRelationOnUpdateAndChangeListener() {
*/
@Test
public void testRelationUpdateListener() {
RelatedObject aTest1 = new RelatedObject();
RelatedObject aTest2 = new RelatedObject();
RelatedObject test1 = new RelatedObject();
RelatedObject test2 = new RelatedObject();

TestListener<String> listener = new TestListener<String>();

aTest1.set(NAME, null).addUpdateListener(listener);
aTest1.set(NAME, "TEST1");
test1.set(NAME, null).addUpdateListener(listener);
test1.set(NAME, "TEST1");
assertEquals("TEST1", relationTarget);
aTest1
test1
.getRelation(NAME)
.get(ListenerTypes.RELATION_UPDATE_LISTENERS)
.remove(listener);
aTest1.set(NAME, "TEST1X");
test1.set(NAME, "TEST1X");
assertEquals("TEST1", relationTarget);

aTest2.set(NAME, null).addUpdateListener(listener);
aTest2.set(NAME, "TEST2");
test2.set(NAME, null).addUpdateListener(listener);
test2.set(NAME, "TEST2");
assertEquals("TEST2", relationTarget);
}

Expand All @@ -124,30 +124,30 @@ public void testRelationUpdateListener() {
*/
@Test
public void testTypeRelationListener() {
RelatedObject aTest1 = new RelatedObject();
RelatedObject aTest2 = new RelatedObject();
RelatedObject test1 = new RelatedObject();
RelatedObject test2 = new RelatedObject();

TestListener<String> listener = new TestListener<>();

NAME.addTypeListener(listener);

aTest1.set(NAME, "TEST1");
test1.set(NAME, "TEST1");
assertEquals("TEST1", relationTarget);

aTest2.set(NAME, "TEST2");
test2.set(NAME, "TEST2");
assertEquals("TEST2", relationTarget);

aTest1.set(NAME, "TEST1A");
test1.set(NAME, "TEST1A");
assertEquals("TEST1A", relationTarget);

aTest2.set(NAME, "TEST2A");
test2.set(NAME, "TEST2A");
assertEquals("TEST2A", relationTarget);

aTest1.deleteRelation(NAME);
test1.deleteRelation(NAME);
assertNull(relationTarget);

relationTarget = "";
aTest2.deleteRelation(NAME);
test2.deleteRelation(NAME);
assertNull(relationTarget);

EventDispatcher<RelationEvent<?>> typeEventDispatcher =
Expand Down
16 changes: 8 additions & 8 deletions src/test/java/org/obrel/space/ObjectSpaceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@ public class ObjectSpaceTest {

private ObjectSpace<Object> testSpace;

private ObjectSpace<Object> aSubSpace1;
private ObjectSpace<Object> subSpace1;

private ObjectSpace<Object> aSubSpace2;
private ObjectSpace<Object> subSpace2;

/**
* Creates the test object space.
*/
@BeforeEach
public void setup() {
testSpace = new RelationSpace<>(true);
aSubSpace1 = new RelationSpace<>(true);
aSubSpace2 = new RelationSpace<>(true);
subSpace1 = new RelationSpace<>(true);
subSpace2 = new RelationSpace<>(true);

testSpace.set(SUBSPACE1, aSubSpace1);
testSpace.set(SUBSPACE2, aSubSpace2);
testSpace.set(SUBSPACE1, subSpace1);
testSpace.set(SUBSPACE2, subSpace2);

testSpace.put("name", "Test");
testSpace.put("port", 1234);
Expand All @@ -78,8 +78,8 @@ public void setup() {
public void testDelete() {
testSpace.delete("subspace1/name");
testSpace.delete("subspace1/port");
assertFalse(aSubSpace1.hasRelation(NAME));
assertFalse(aSubSpace1.hasRelation(PORT));
assertFalse(subSpace1.hasRelation(NAME));
assertFalse(subSpace1.hasRelation(PORT));

testSpace.delete("subspace1");
assertFalse(testSpace.hasRelation(SUBSPACE1));
Expand Down

0 comments on commit 5f64282

Please sign in to comment.