/** * Test that the most specific classification is used when a group of intermediate specificity is * queried. */ @Test public void testOverriddenIndirectSuperclass() { classifier.addClass(Room.BATHROOM, Arrays.asList(Creature.BIRD)); classifier.addClass(Room.BEDROOM, Arrays.asList(Creature.GREENFINCH)); Assert.assertEquals(classifier.getClass(Creature.BIRD), Room.BATHROOM); Assert.assertEquals(classifier.getClass(Creature.FINCH), Room.BATHROOM); Assert.assertEquals(classifier.getClass(Creature.GREENFINCH), Room.BEDROOM); }
/** Test a more complex classification scenario. */ @Test public void testComplex() { classifier.addClass( Room.KITCHEN, Arrays.asList(Creature.MAMMAL, Creature.DACHSHUND, Creature.HAKE)); classifier.addClass(Room.BEDROOM, Arrays.asList(Creature.FISH, Creature.DOG)); classifier.addClass(Room.DRAWING_ROOM, Arrays.asList(Creature.FINCH, Creature.LEVIATHAN)); classifier.addClass(Room.BATHROOM, Arrays.asList(Creature.BIRD)); Assert.assertEquals(classifier.getClass(Creature.MAMMAL), Room.KITCHEN); Assert.assertEquals(classifier.getClass(Creature.CAT), Room.KITCHEN); Assert.assertEquals(classifier.getClass(Creature.DOG), Room.BEDROOM); Assert.assertEquals(classifier.getClass(Creature.DACHSHUND), Room.KITCHEN); Assert.assertEquals(classifier.getClass(Creature.FISH), Room.BEDROOM); Assert.assertEquals(classifier.getClass(Creature.COD), Room.BEDROOM); Assert.assertEquals(classifier.getClass(Creature.HAKE), Room.KITCHEN); Assert.assertEquals(classifier.getClass(Creature.BIRD), Room.BATHROOM); Assert.assertEquals(classifier.getClass(Creature.FINCH), Room.DRAWING_ROOM); Assert.assertEquals(classifier.getClass(Creature.GREENFINCH), Room.DRAWING_ROOM); Assert.assertEquals(classifier.getClass(Creature.MAGPIE), Room.BATHROOM); Assert.assertEquals(classifier.getClass(Creature.LEVIATHAN), Room.DRAWING_ROOM); }
/** Test that an unknown group is not classified. */ @Test public void testUnknown() { Assert.assertNull(classifier.getClass(Creature.LEVIATHAN)); }
/** Test that the same classification may be asserted repeatedly for a group. */ @Test public void testSameConsistent() { classifier.addClass(Room.KITCHEN, Arrays.asList(Creature.COD)); classifier.addClass(Room.KITCHEN, Arrays.asList(Creature.COD)); Assert.assertEquals(classifier.getClass(Creature.COD), Room.KITCHEN); }
/** Test that classification succeeds when a subclass of the known group is queried. */ @Test public void testSuperclass() { classifier.addClass(Room.DRAWING_ROOM, Arrays.asList(Creature.BIRD)); Assert.assertEquals(classifier.getClass(Creature.FINCH), Room.DRAWING_ROOM); }