@Test public void testSettingParentLocation() { AbstractLocation location = new ConcreteLocation(); AbstractLocation locationSub = new ConcreteLocation(); locationSub.setParent(location); assertEquals(ImmutableList.copyOf(location.getChildren()), ImmutableList.of(locationSub)); assertEquals(locationSub.getParent(), location); }
@Test public void testClearingParentLocation() { AbstractLocation location = new ConcreteLocation(); AbstractLocation locationSub = new ConcreteLocation(); locationSub.setParent(location); locationSub.setParent(null); assertEquals(ImmutableList.copyOf(location.getChildren()), Collections.emptyList()); assertEquals(locationSub.getParent(), null); }
@Test public void constructorParentLocationReturnsExpectedLocation() { AbstractLocation parent = new ConcreteLocation(MutableMap.of("name", "Middle Earth")); AbstractLocation child = new ConcreteLocation(MutableMap.of("name", "The Shire", "parentLocation", parent)); assertEquals(child.getParent(), parent); assertEquals(ImmutableList.copyOf(parent.getChildren()), ImmutableList.of(child)); }
@Test public void testAddChildToParentLocationReturnsExpectedLocation() { AbstractLocation parent = new ConcreteLocation(MutableMap.of("id", "1")); AbstractLocation child = new ConcreteLocation(MutableMap.of("id", "2")); parent.addChild(child); assertEquals(child.getParent(), parent); assertEquals(ImmutableList.copyOf(parent.getChildren()), ImmutableList.of(child)); }
@Test public void setParentLocationReturnsExpectedLocation() { AbstractLocation parent = new ConcreteLocation(MutableMap.of("name", "Middle Earth")); AbstractLocation child = new ConcreteLocation(MutableMap.of("name", "The Shire")); child.setParent(parent); assertEquals(child.getParent(), parent); assertEquals(ImmutableList.copyOf(parent.getChildren()), ImmutableList.of(child)); }