use of org.neo4j.collection.RawIterator in project neo4j by neo4j.
the class CsvInputTest method shouldNotReportNoRelationshipTypeIfDecorated.
@Test
public void shouldNotReportNoRelationshipTypeIfDecorated() {
// given
String sourceDescription = "source";
Supplier<CharReadable> headerSource = () -> wrap(dataWithSourceDescription(":START_ID,:END_ID", sourceDescription), 3);
Iterable<DataFactory> data = datas(config -> new Data() {
@Override
public RawIterator<CharReadable, IOException> stream() {
return asRawIterator(iterator(headerSource.get()));
}
@Override
public Decorator decorator() {
return defaultRelationshipType("MyType");
}
});
CsvInput.Monitor monitor = mock(CsvInput.Monitor.class);
// when
new CsvInput(datas(), defaultFormatNodeFileHeader(), data, defaultFormatRelationshipFileHeader(), IdType.INTEGER, COMMAS, monitor, INSTANCE);
// then
verify(monitor, never()).noRelationshipTypeSpecified(sourceDescription);
}
use of org.neo4j.collection.RawIterator in project neo4j by neo4j.
the class CsvInputTest method shouldNotReportNoNodeLabelsIfDecorated.
@Test
public void shouldNotReportNoNodeLabelsIfDecorated() {
// given
String sourceDescription = "source";
Supplier<CharReadable> headerSource = () -> wrap(dataWithSourceDescription(":ID", sourceDescription), 3);
Iterable<DataFactory> data = datas(config -> new Data() {
@Override
public RawIterator<CharReadable, IOException> stream() {
return asRawIterator(iterator(headerSource.get()));
}
@Override
public Decorator decorator() {
return additiveLabels(new String[] { "MyLabel" });
}
});
CsvInput.Monitor monitor = mock(CsvInput.Monitor.class);
// when
new CsvInput(data, defaultFormatNodeFileHeader(), datas(), defaultFormatRelationshipFileHeader(), IdType.INTEGER, COMMAS, monitor, INSTANCE);
// then
verify(monitor, never()).noRelationshipTypeSpecified(sourceDescription);
}
use of org.neo4j.collection.RawIterator in project neo4j by neo4j.
the class CsvInputTest method shouldReportNoRelationshipType.
@Test
public void shouldReportNoRelationshipType() {
// given
String sourceDescription = "source";
Supplier<CharReadable> headerSource = () -> wrap(dataWithSourceDescription(":START_ID,:END_ID", sourceDescription), 3);
Iterable<DataFactory> data = datas(config -> new Data() {
@Override
public RawIterator<CharReadable, IOException> stream() {
return asRawIterator(iterator(headerSource.get()));
}
@Override
public Decorator decorator() {
return NO_DECORATOR;
}
});
CsvInput.Monitor monitor = mock(CsvInput.Monitor.class);
// when
new CsvInput(datas(), defaultFormatNodeFileHeader(), data, defaultFormatRelationshipFileHeader(), IdType.INTEGER, COMMAS, monitor, INSTANCE);
// then
verify(monitor).noRelationshipTypeSpecified(sourceDescription);
}
use of org.neo4j.collection.RawIterator in project neo4j by neo4j.
the class ProceduresTest method shouldMakeContextAvailable.
@Test
void shouldMakeContextAvailable() throws Throwable {
// Given
procs.register(new CallableProcedure.BasicProcedure(signature) {
@Override
public RawIterator<AnyValue[], ProcedureException> apply(Context ctx, AnyValue[] input, ResourceTracker resourceTracker) {
return RawIterator.<AnyValue[], ProcedureException>of(new AnyValue[] { stringValue(ctx.thread().getName()) });
}
});
Context ctx = prepareContext();
ProcedureHandle procedureHandle = procs.procedure(signature.name());
// When
RawIterator<AnyValue[], ProcedureException> result = procs.callProcedure(ctx, procedureHandle.id(), new AnyValue[0], EMPTY_RESOURCE_TRACKER);
// Then
assertThat(asList(result)).contains(new AnyValue[] { stringValue(Thread.currentThread().getName()) });
}
use of org.neo4j.collection.RawIterator in project neo4j by neo4j.
the class ClusterOverviewProcedure method apply.
@Override
public RawIterator<Object[], ProcedureException> apply(Context ctx, Object[] input) throws ProcedureException {
List<ReadWriteEndPoint> endpoints = new ArrayList<>();
CoreTopology coreTopology = topologyService.coreServers();
Set<MemberId> coreMembers = coreTopology.members().keySet();
MemberId leader = null;
try {
leader = leaderLocator.getLeader();
} catch (NoLeaderFoundException e) {
log.debug("No write server found. This can happen during a leader switch.");
}
for (MemberId memberId : coreMembers) {
Optional<CoreServerInfo> coreServerInfo = coreTopology.find(memberId);
if (coreServerInfo.isPresent()) {
Role role = memberId.equals(leader) ? Role.LEADER : Role.FOLLOWER;
endpoints.add(new ReadWriteEndPoint(coreServerInfo.get().connectors(), role, memberId.getUuid(), asList(coreServerInfo.get().groups())));
} else {
log.debug("No Address found for " + memberId);
}
}
for (Map.Entry<MemberId, ReadReplicaInfo> readReplica : topologyService.readReplicas().members().entrySet()) {
ReadReplicaInfo readReplicaInfo = readReplica.getValue();
endpoints.add(new ReadWriteEndPoint(readReplicaInfo.connectors(), Role.READ_REPLICA, readReplica.getKey().getUuid(), asList(readReplicaInfo.groups())));
}
endpoints.sort(comparing(o -> o.addresses().toString()));
return map((endpoint) -> new Object[] { endpoint.memberId().toString(), endpoint.addresses().uriList().stream().map(URI::toString).toArray(), endpoint.role().name(), endpoint.groups() }, asRawIterator(endpoints.iterator()));
}
Aggregations