DocumentVisibilityAdapter { public static Document toDocument(final byte[] expression) { DocumentVisibility dv; if (expression == null) { dv = MongoDbRdfConstants.EMPTY_DV; } else { dv = new DocumentVisibility(expression); } return toDocument(dv); } private  DocumentVisibilityAdapter(); static Document toDocument(final byte[] expression); static Document toDocument(final DocumentVisibility documentVisibility); static DocumentVisibility toDocumentVisibility(final Document doc); static final String DOCUMENT_VISIBILITY_KEY; }
@Test public void testToDocument() { final DocumentVisibility dv = new DocumentVisibility("A"); final Document document = DocumentVisibilityAdapter.toDocument(dv); final Document expected = Document.parse( "{" + "documentVisibility : [[\"A\"]]" + "}" ); assertEquals(expected, document); }
@Test public void testToDocument_and() { final DocumentVisibility dv = new DocumentVisibility("A&B&C"); final Document document = DocumentVisibilityAdapter.toDocument(dv); final Document expected = Document.parse( "{" + "documentVisibility : [[\"A\", \"B\", \"C\"]]" + "}" ); assertEquals(expected, document); }
@Test public void testToDocument_or() { final DocumentVisibility dv = new DocumentVisibility("A|B|C"); final Document document = DocumentVisibilityAdapter.toDocument(dv); final Document expected = Document.parse( "{" + "documentVisibility : [[\"C\"], [\"B\"], [\"A\"]]" + "}" ); assertEquals(expected, document); }
@Test public void testToDocument_Expression() { final DocumentVisibility dv = new DocumentVisibility("A&B&C"); final Document document = DocumentVisibilityAdapter.toDocument(dv.getExpression()); final Document expected = Document.parse( "{" + "documentVisibility : [[\"A\", \"B\", \"C\"]]" + "}" ); assertEquals(expected, document); }
@Test public void testToDocument_nullExpression() { final Document document = DocumentVisibilityAdapter.toDocument((byte[])null); final Document expected = Document.parse( "{" + "documentVisibility : []" + "}" ); assertEquals(expected, document); }
@Test public void testToDocument_nullDocumentVisibility() { final Document document = DocumentVisibilityAdapter.toDocument((DocumentVisibility)null); final Document expected = Document.parse( "{" + "documentVisibility : []" + "}" ); assertEquals(expected, document); }
@Test public void testToDocument_emptyDocumentVisibility() { final Document document = DocumentVisibilityAdapter.toDocument(MongoDbRdfConstants.EMPTY_DV); final Document expected = Document.parse( "{" + "documentVisibility : []" + "}" ); assertEquals(expected, document); }