use of org.neo4j.dbms.DatabaseState in project neo4j by neo4j.
the class CommunityDatabaseStateProcedureTest method shouldThrowWhenDatabaseNotFound.
@Test
void shouldThrowWhenDatabaseNotFound() throws ProcedureException {
// given
var existing = idRepository.getRaw("existing");
var nonExisting = idRepository.getRaw("nonExisting");
idRepository.filter(nonExisting.name());
Map<NamedDatabaseId, DatabaseState> states = Map.of(existing, new CommunityDatabaseState(existing, true, false, null));
var stateService = new StubDatabaseStateService(states, CommunityDatabaseState::unknown);
var procedure = procedure(stateService);
// when/then
// Should not throw
procedure.apply(mock(Context.class), new AnyValue[] { stringValue(existing.name()) }, mock(ResourceTracker.class));
// Should throw
assertThrows(ProcedureException.class, () -> procedure.apply(mock(Context.class), new AnyValue[] { stringValue(nonExisting.name()) }, mock(ResourceTracker.class)));
}
use of org.neo4j.dbms.DatabaseState in project neo4j by neo4j.
the class CommunityDatabaseStateProcedureTest method shouldReturnEmptyErrorForNoError.
@Test
void shouldReturnEmptyErrorForNoError() throws ProcedureException {
// given
var existing = idRepository.getRaw("existing");
Map<NamedDatabaseId, DatabaseState> states = Map.of(existing, new CommunityDatabaseState(existing, true, false, null));
var stateService = new StubDatabaseStateService(states, CommunityDatabaseState::unknown);
var procedure = procedure(stateService);
// when
var result = procedure.apply(mock(Context.class), new AnyValue[] { stringValue(existing.name()) }, mock(ResourceTracker.class));
var returned = Arrays.asList(result.next());
// then
assertEquals(4, returned.size(), "Procedure result should have 4 columns: role, address, state and error message");
var roleColumn = stringValue("standalone");
var addressColumn = stringValue("localhost:7687");
var statusColumn = stringValue("online");
var errorColumn = stringValue("");
assertEquals(Arrays.asList(roleColumn, addressColumn, statusColumn, errorColumn), returned, "Error column should be empty");
}
Aggregations