Skip to content

Commit

Permalink
repo-sqale: implemented repositorySelfTest()
Browse files Browse the repository at this point in the history
Also, unimplemented methods now throw UnsupportedOperationException
instead of doing nothing or returning default values.
  • Loading branch information
virgo47 committed Jul 19, 2021
1 parent 4ad1130 commit 2398549
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -793,8 +793,8 @@ public <T extends ObjectType> SearchResultMetadata searchObjectsIterative(
Class<T> type, ObjectQuery query, ResultHandler<T> handler,
Collection<SelectorOptions<GetOperationOptions>> options, boolean strictlySequential,
OperationResult parentResult) throws SchemaException {
return null;
// TODO
throw new UnsupportedOperationException();
}

@Override
Expand Down Expand Up @@ -835,22 +835,22 @@ public <T extends Containerable> SearchResultList<T> searchContainers(
@Override
public boolean isAnySubordinate(String upperOrgOid, Collection<String> lowerObjectOids)
throws SchemaException {
return false;
// TODO
throw new UnsupportedOperationException();
}

@Override
public <O extends ObjectType> boolean isDescendant(PrismObject<O> object, String orgOid)
throws SchemaException {
return false;
// TODO
throw new UnsupportedOperationException();
}

@Override
public <O extends ObjectType> boolean isAncestor(PrismObject<O> object, String oid)
throws SchemaException {
return false;
// TODO
throw new UnsupportedOperationException();
}

@Override
Expand All @@ -863,16 +863,16 @@ public <F extends FocusType> PrismObject<F> searchShadowOwner(String shadowOid,
@Override
public long advanceSequence(String oid, OperationResult parentResult)
throws ObjectNotFoundException, SchemaException {
return 0;
// TODO
throw new UnsupportedOperationException();
}

@Override
public void returnUnusedValuesToSequence(
String oid, Collection<Long> unusedValues, OperationResult parentResult)
throws ObjectNotFoundException, SchemaException {

// TODO
throw new UnsupportedOperationException();
}

@Override
Expand Down Expand Up @@ -963,7 +963,13 @@ private String getTransactionIsolation(

@Override
public void repositorySelfTest(OperationResult parentResult) {
// TODO - SELECT 1 + latency info if we can put it in the result?
try (JdbcSession jdbcSession = repositoryContext.newJdbcSession().startTransaction()) {
long startMs = System.currentTimeMillis();
jdbcSession.executeStatement("select 1");
parentResult.addReturn("database-round-trip-ms", System.currentTimeMillis() - startMs);
} catch (Exception e) {
parentResult.recordFatalError(e);
}
}

@Override
Expand All @@ -977,12 +983,15 @@ public RepositoryQueryDiagResponse executeQueryDiagnostics(
RepositoryQueryDiagRequest request, OperationResult result) {

// TODO search like containers + dry run?
throw new UnsupportedOperationException();

/*
RepositoryQueryDiagResponse response = new RepositoryQueryDiagResponse(
null, null, Map.of());
// objects, implementationLevelQuery, implementationLevelQueryParameters);
return response;
*/
}

@Override
Expand All @@ -991,8 +1000,8 @@ public <O extends ObjectType> boolean selectorMatches(
ObjectFilterExpressionEvaluator filterEvaluator, Trace logger, String logMessagePrefix)
throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException,
CommunicationException, ConfigurationException, SecurityViolationException {
return false;
// TODO
throw new UnsupportedOperationException();
}

@Override
Expand Down Expand Up @@ -1080,6 +1089,7 @@ public <T extends ObjectType> void addDiagnosticInformation(Class<T> type, Strin
throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException {

// TODO
throw new UnsupportedOperationException();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ public void test000Sanity() {
assertThat(select(aliasFor(QReference.CLASS))).isEmpty();
}

@Test
public void test010TestRepositorySelfTest() {
OperationResult result = createOperationResult();

when("repository self test is called");
repositoryService.repositorySelfTest(result);

expect("operation is successful and contains info about round-trip time to DB");
assertThatOperationResult(result).isSuccess();
assertThat(result.getReturn("database-round-trip-ms"))
.isNotNull()
.hasSize(1);
}

@Test
public void test100AddObject() throws ObjectAlreadyExistsException, SchemaException {
OperationResult result = createOperationResult();
Expand Down

0 comments on commit 2398549

Please sign in to comment.