use of org.neo4j.driver.summary.SummaryCounters in project neo4j by neo4j.
the class PrettyPrinterTest method returnStatisticsForEmptyRecords.
@Test
public void returnStatisticsForEmptyRecords() {
// given
ResultSummary resultSummary = mock(ResultSummary.class);
SummaryCounters summaryCounters = mock(SummaryCounters.class);
BoltResult result = new ListBoltResult(Collections.emptyList(), resultSummary);
when(resultSummary.counters()).thenReturn(summaryCounters);
when(summaryCounters.labelsAdded()).thenReturn(1);
when(summaryCounters.nodesCreated()).thenReturn(10);
// when
String actual = verbosePrinter.format(result);
// then
assertThat(actual, containsString("Added 10 nodes, Added 1 labels"));
}
use of org.neo4j.driver.summary.SummaryCounters in project neo4j by neo4j.
the class StatisticsCollector method collectStatistics.
private String collectStatistics(@Nonnull ResultSummary summary) {
List<String> statistics = new ArrayList<>();
SummaryCounters counters = summary.counters();
if (counters == null) {
return "";
}
if (counters.nodesCreated() != 0) {
statistics.add(String.format("Added %d nodes", counters.nodesCreated()));
}
if (counters.nodesDeleted() != 0) {
statistics.add(String.format("Deleted %d nodes", counters.nodesDeleted()));
}
if (counters.relationshipsCreated() != 0) {
statistics.add(String.format("Created %d relationships", counters.relationshipsCreated()));
}
if (counters.relationshipsDeleted() != 0) {
statistics.add(String.format("Deleted %d relationships", counters.relationshipsDeleted()));
}
if (counters.propertiesSet() != 0) {
statistics.add(String.format("Set %d properties", counters.propertiesSet()));
}
if (counters.labelsAdded() != 0) {
statistics.add(String.format("Added %d labels", counters.labelsAdded()));
}
if (counters.labelsRemoved() != 0) {
statistics.add(String.format("Removed %d labels", counters.labelsRemoved()));
}
if (counters.indexesAdded() != 0) {
statistics.add(String.format("Added %d indexes", counters.indexesAdded()));
}
if (counters.indexesRemoved() != 0) {
statistics.add(String.format("Removed %d indexes", counters.indexesRemoved()));
}
if (counters.constraintsAdded() != 0) {
statistics.add(String.format("Added %d constraints", counters.constraintsAdded()));
}
if (counters.constraintsRemoved() != 0) {
statistics.add(String.format("Removed %d constraints", counters.constraintsRemoved()));
}
return statistics.stream().collect(Collectors.joining(", "));
}
use of org.neo4j.driver.summary.SummaryCounters in project neo4j by neo4j.
the class StatisticsCollectorTest method returnStatisticsForDefaultFormatting.
@Test
public void returnStatisticsForDefaultFormatting() throws Exception {
// given
ResultSummary resultSummary = mock(ResultSummary.class);
SummaryCounters summaryCounters = mock(SummaryCounters.class);
when(resultSummary.counters()).thenReturn(summaryCounters);
when(summaryCounters.labelsAdded()).thenReturn(1);
when(summaryCounters.nodesCreated()).thenReturn(10);
// when
String actual = new StatisticsCollector(Format.VERBOSE).collect(resultSummary);
// then
assertThat(actual, is("Added 10 nodes, Added 1 labels"));
}
Aggregations