### Question:
CreateVertexLogEntry implements LogEntry { @Override public void appendToLog(LogOutput dbLog) { dbLog.newVertex(vertex); StreamIterator.stream(vertex.properties()) .filter(property -> !propertiesToIgnore.contains(property.key())) .forEach(dbLog::newProperty); } CreateVertexLogEntry(Vertex vertex);   CreateVertexLogEntry(Vertex vertex, Set<String> propertiesToIgnore); @Override void appendToLog(LogOutput dbLog); static final Logger LOG; }### Answer:
@Test public void appendToLogAddsNewVertexLineForAVertexWithoutPreviousVersions() { Vertex vertex = vertex().build(); LogOutput dbLog = mock(LogOutput.class); CreateVertexLogEntry instance = new CreateVertexLogEntry(vertex); instance.appendToLog(dbLog); verify(dbLog).newVertex(vertex); }
@Test public void appendToLogAddsANewPropertyLineForEachNewPropertyAfter() { String key1 = "property1"; String key2 = "property2"; String key3 = "property3"; Vertex vertex = vertex() .withProperty(key1, "value") .withProperty(key2, "value") .withProperty(key3, "value") .build(); LogOutput dbLog = mock(LogOutput.class); CreateVertexLogEntry instance = new CreateVertexLogEntry(vertex); instance.appendToLog(dbLog); verify(dbLog).newProperty(argThat(likeProperty().withKey(key1))); verify(dbLog).newProperty(argThat(likeProperty().withKey(key2))); verify(dbLog).newProperty(argThat(likeProperty().withKey(key3))); }
@Test public void appendToLogFirstAddsNewVertexThanTheNewProperties() { String key1 = "property1"; Vertex vertex = vertex() .withProperty(key1, "value") .build(); LogOutput dbLog = mock(LogOutput.class); CreateVertexLogEntry vertexLogEntry = new CreateVertexLogEntry(vertex); vertexLogEntry.appendToLog(dbLog); InOrder inOrder = inOrder(dbLog); inOrder.verify(dbLog).newVertex(vertex); inOrder.verify(dbLog).newProperty(argThat(likeProperty().withKey(key1))); }
@Test public void appendToLogIgnoresThePropertiesToIgnore() { LogOutput logOutput = mock(LogOutput.class); String propToIgnore = "propToIgnore"; Vertex vertex = vertex().withProperty(propToIgnore, "value").build(); CreateVertexLogEntry instance = new CreateVertexLogEntry(vertex, Sets.newHashSet(propToIgnore)); instance.appendToLog(logOutput); verify(logOutput, never()).newProperty(argThat(likeProperty().withKey(propToIgnore))); }