Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v2-alpha' into gh-2630-example-r…
Browse files Browse the repository at this point in the history
…eal-federatedstore
  • Loading branch information
GCHQDev404 committed Oct 25, 2022
2 parents a2f4796 + 20413bf commit 1fe1a8e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
<param name="ConversionPattern" value="%c{3} %p %x - %m%n"/>
</layout>
</appender>
<!-- Fix to filter out warnings from this class about
Accumulo Client was garbage collected without being closed -->
<logger name="org.apache.accumulo.core.singletons.SingletonReservation">
<level value="error"/>
</logger>
<root>
<priority value="warn"></priority>
<appender-ref ref="console"></appender-ref>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
@Since("2.0.0")
public class FederatedOperationHandler<INPUT, OUTPUT> implements OperationHandler<FederatedOperation<INPUT, OUTPUT>> {

public static final String ERROR_WHILE_RUNNING_OPERATION_ON_GRAPHS = "Error while running operation on graphs";
public static final String ERROR_WHILE_RUNNING_OPERATION_ON_GRAPHS_FORMAT = "Error while running operation on graphs, due to: %s";

@Override
public Object doOperation(final FederatedOperation<INPUT, OUTPUT> operation, final Context context, final Store store) throws OperationException {
Expand Down Expand Up @@ -80,7 +80,7 @@ private Iterable getAllGraphResults(final FederatedOperation<INPUT, OUTPUT> oper

return results;
} catch (final Exception e) {
throw new OperationException(ERROR_WHILE_RUNNING_OPERATION_ON_GRAPHS, e);
throw new OperationException(String.format(ERROR_WHILE_RUNNING_OPERATION_ON_GRAPHS_FORMAT, e), e);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -198,13 +199,10 @@ public void shouldThrowStoreException() throws Exception {
when(federatedStore.getGraphs(testUser, null, federatedOperation)).thenReturn(asList(graph1, graph2, graph3, graph4));

// When
try {
Object ignore = new FederatedOperationHandler<Void, Iterable<? extends Element>>().doOperation(federatedOperation, context, federatedStore);
fail("Exception Not thrown");
} catch (OperationException e) {
assertEquals(FederatedOperationHandler.ERROR_WHILE_RUNNING_OPERATION_ON_GRAPHS, e.getMessage());
assertTrue(e.getCause().getMessage().contains(errorMessage));
}
assertThatExceptionOfType(OperationException.class)
.isThrownBy(() -> new FederatedOperationHandler<Void, Iterable<? extends Element>>().doOperation(federatedOperation, context, federatedStore))
.withMessageContaining(String.format(FederatedOperationHandler.ERROR_WHILE_RUNNING_OPERATION_ON_GRAPHS_FORMAT, ""))
.withStackTraceContaining(errorMessage);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
<logger name="uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedAddGraphHandlerParent">
<level value="error"/>
</logger>
<!-- Fix to filter out warnings from this class about
Accumulo Client was garbage collected without being closed -->
<logger name="org.apache.accumulo.core.singletons.SingletonReservation">
<level value="error"/>
</logger>
<root>
<priority value="warn"></priority>
<appender-ref ref="console"></appender-ref>
Expand Down

0 comments on commit 1fe1a8e

Please sign in to comment.