src/test/java/org/thegalactic/context/constraint/categorical/CategoricalStorageTest.java
@Test
    public void testIntersection() {
        CategoricalModel model = CategoricalModel.create();
        CategoricalAttribute attribute = model.addAttribute();
        CategoricalValue value1 = attribute.addValue("Test1");
        CategoricalValue value2 = attribute.addValue("Test2");
        CategoricalValue value3 = attribute.addValue("Test3");
        CategoricalValue value4 = attribute.addValue("Test4");
        CategoricalStorage storage1 = CategoricalStorage.create(model);
        CategoricalStorage storage2 = CategoricalStorage.create(model);
        storage1.set(value1, true);
        storage1.set(value2, true);
        storage1.set(value3, false);
        storage1.set(value4, false);
        storage2.set(value1, true);
        storage2.set(value2, false);
        storage2.set(value3, true);
        storage2.set(value4, false);
        storage1.intersection(storage2);
        assertEquals(true, storage1.get(value1));
        assertEquals(false, storage1.get(value2));
        assertEquals(false, storage1.get(value3));
        assertEquals(false, storage1.get(value4));
        try {
            storage2 = CategoricalStorage.create(CategoricalModel.create());
            storage1.union(storage2);
            fail("An IllegalArgumentException must be thrown");
        } catch (IllegalArgumentException e) {
            assertEquals("CategoricalStorage objects must have the same model", e.getMessage());
        }
    }
/**
     * Test of intersection method, of class CategoricalStorage.
     */
Test of intersection method, of class CategoricalStorage.
Test of intersection method of class CategoricalStorage .
@Test
    public void testIntersection() {
        CategoricalModel model = CategoricalModel.create();
        CategoricalAttribute attribute = model.addAttribute();
        CategoricalValue value1 = attribute.addValue("Test1");
        CategoricalValue value2 = attribute.addValue("Test2");
        CategoricalValue value3 = attribute.addValue("Test3");
        CategoricalValue value4 = attribute.addValue("Test4");
        CategoricalStorage storage1 = CategoricalStorage.create(model);
        CategoricalStorage storage2 = CategoricalStorage.create(model);
        storage1.set(value1, true);
        storage1.set(value2, true);
        storage1.set(value3, false);
        storage1.set(value4, false);
        storage2.set(value1, true);
        storage2.set(value2, false);
        storage2.set(value3, true);
        storage2.set(value4, false);
        storage1.intersection(storage2);
        assertEquals(true, storage1.get(value1));
        assertEquals(false, storage1.get(value2));
        assertEquals(false, storage1.get(value3));
        assertEquals(false, storage1.get(value4));
        try {
            storage2 = CategoricalStorage.create(CategoricalModel.create());
            storage1.union(storage2);
            fail("An IllegalArgumentException must be thrown");
        } catch (IllegalArgumentException e) {
            assertEquals("CategoricalStorage objects must have the same model", e.getMessage());
        }
    }
@ Test public void testIntersection ( ) { CategoricalModel model = CategoricalModel . create ( ) ; CategoricalAttribute attribute = model . addAttribute ( ) ; CategoricalValue value1 = attribute . addValue ( "Test1" ) ; CategoricalValue value2 = attribute . addValue ( "Test2" ) ; CategoricalValue value3 = attribute . addValue ( "Test3" ) ; CategoricalValue value4 = attribute . addValue ( "Test4" ) ; CategoricalStorage storage1 = CategoricalStorage . create ( model ) ; CategoricalStorage storage2 = CategoricalStorage . create ( model ) ; storage1 . set ( value1 , true ) ; storage1 . set ( value2 , true ) ; storage1 . set ( value3 , false ) ; storage1 . set ( value4 , false ) ; storage2 . set ( value1 , true ) ; storage2 . set ( value2 , false ) ; storage2 . set ( value3 , true ) ; storage2 . set ( value4 , false ) ; storage1 . intersection ( storage2 ) ; assertEquals ( true , storage1 . get ( value1 ) ) ; assertEquals ( false , storage1 . get ( value2 ) ) ; assertEquals ( false , storage1 . get ( value3 ) ) ; assertEquals ( false , storage1 . get ( value4 ) ) ; try { storage2 = CategoricalStorage . create ( CategoricalModel . create ( ) ) ; storage1 . union ( storage2 ) ; fail ( "An IllegalArgumentException must be thrown" ) ; } catch ( IllegalArgumentException e ) { assertEquals ( "CategoricalStorage objects must have the same model" , e . getMessage ( ) ) ; } }
Test of intersection method, of class CategoricalStorage.
Test of intersection method of class CategoricalStorage .