DisjunctiveNormalFormConverter { public static byte[][] createTruthTableInputs(final Node node, final byte[] expression) { final List<String> terms = findNodeTerms(node, expression); return createTruthTableInputs(terms); } private  DisjunctiveNormalFormConverter(); static DocumentVisibility createDnfDocumentVisibility(final String expression); static DocumentVisibility createDnfDocumentVisibility(final byte[] expression); static DocumentVisibility convertToDisjunctiveNormalForm(final DocumentVisibility documentVisibility); static List<String> findNodeTerms(final Node node, final byte[] expression); static byte[][] createTruthTableInputs(final Node node, final byte[] expression); static byte[][] createTruthTableInputs(final List<String> terms); static byte[][] createTruthTableInputs(final int termNumber);  }
@Test (expected=NullPointerException.class) public void testTruthTableNullList() { final List<String> list = null; DisjunctiveNormalFormConverter.createTruthTableInputs(list); }
@Test (expected=NullPointerException.class) public void testTruthTableNullNode() { final Node node = null; final byte[] expression = new DocumentVisibility("A").getExpression(); DisjunctiveNormalFormConverter.createTruthTableInputs(node, expression); }
@Test (expected=NullPointerException.class) public void testTruthTableNullExpression() { final Node node = new DocumentVisibility("A").getParseTree(); final byte[] expression = null; DisjunctiveNormalFormConverter.createTruthTableInputs(node, expression); }
@Test public void testTruthTableSize() { final byte[][] truthTable = DisjunctiveNormalFormConverter.createTruthTableInputs(0); final byte[][] expected = { {} }; assertArrayEquals(expected, truthTable); }
@Test public void testTruthTableSize1() { final byte[][] truthTable = DisjunctiveNormalFormConverter.createTruthTableInputs(1); final byte[][] expected= { {0}, {1} }; assertArrayEquals(expected, truthTable); }
@Test public void testTruthTableSize2FromList() { final byte[][] truthTable = DisjunctiveNormalFormConverter.createTruthTableInputs(ImmutableList.of("A", "B")); final byte[][] expected = { {0, 0}, {0, 1}, {1, 0}, {1, 1} }; assertArrayEquals(expected, truthTable); }
@Test public void testTruthTableSize3FromNode() { final DocumentVisibility dv = new DocumentVisibility("(A&B)|(A&C)"); final byte[][] truthTable = DisjunctiveNormalFormConverter.createTruthTableInputs(dv.getParseTree(), dv.getExpression()); final byte[][] expected = { {0, 0, 0}, {0, 0, 1}, {0, 1, 0}, {0, 1, 1}, {1, 0, 0}, {1, 0, 1}, {1, 1, 0}, {1, 1, 1} }; assertArrayEquals(expected, truthTable); }