use of org.junit.jupiter.api.function.ThrowingSupplier in project Mal4J by KatsuteDev.
the class TestUser method testMangaAffinity.
@SuppressWarnings("SpellCheckingInspection")
@Test
final void testMangaAffinity() {
final MangaAffinity affinity = user.getMangaAffinity("Xinil");
annotateTest(() -> assertEquals(affinity.getShared().length, affinity.getSharedCount()));
annotateTest(() -> assertDoesNotThrow((ThrowingSupplier<Float>) affinity::getAffinity));
}
use of org.junit.jupiter.api.function.ThrowingSupplier in project JOSM_MapWIthAI_plugin by KaartGroup.
the class DataConflationSenderTest method testEmptyUrl.
@Test
void testEmptyUrl() {
MapWithAIConflationCategoryMock.url = "";
new MapWithAIConflationCategoryMock();
final DataSet external = new DataSet(new Node(LatLon.NORTH_POLE));
final DataSet openstreetmap = new DataSet(new Node(LatLon.ZERO));
final DataConflationSender dataConflationSender = new DataConflationSender(MapWithAICategory.OTHER, openstreetmap, external);
dataConflationSender.run();
assertNull(assertDoesNotThrow((ThrowingSupplier<DataSet>) dataConflationSender::get));
}
use of org.junit.jupiter.api.function.ThrowingSupplier in project Mal4J by KatsuteDev.
the class TestUser method testAnimeAffinity.
@SuppressWarnings("SpellCheckingInspection")
@Test
final void testAnimeAffinity() {
final AnimeAffinity affinity = user.getAnimeAffinity("Xinil");
annotateTest(() -> assertEquals(affinity.getShared().length, affinity.getSharedCount()));
annotateTest(() -> assertDoesNotThrow((ThrowingSupplier<Float>) affinity::getAffinity));
}
use of org.junit.jupiter.api.function.ThrowingSupplier in project kogito-apps by kiegroup.
the class ExplanationServiceImplTest method testCounterfactualsExplainAsyncSuccess.
@SuppressWarnings("unchecked")
void testCounterfactualsExplainAsyncSuccess(ThrowingSupplier<BaseExplainabilityResult> invocation) {
when(instance.stream()).thenReturn(Stream.of(cfExplainerServiceHandlerMock));
when(cfExplainerMock.explainAsync(any(Prediction.class), eq(predictionProviderMock), any(Consumer.class))).thenReturn(CompletableFuture.completedFuture(COUNTERFACTUAL_RESULT));
BaseExplainabilityResult result = assertDoesNotThrow(invocation);
assertNotNull(result);
assertTrue(result instanceof CounterfactualExplainabilityResult);
CounterfactualExplainabilityResult counterfactualResult = (CounterfactualExplainabilityResult) result;
assertEquals(EXECUTION_ID, counterfactualResult.getExecutionId());
assertEquals(COUNTERFACTUAL_ID, counterfactualResult.getCounterfactualId());
assertSame(ExplainabilityStatus.SUCCEEDED, counterfactualResult.getStatus());
assertNull(counterfactualResult.getStatusDetails());
assertEquals(COUNTERFACTUAL_RESULT.getEntities().size(), counterfactualResult.getInputs().size());
assertEquals(COUNTERFACTUAL_RESULT.getOutput().size(), counterfactualResult.getOutputs().size());
assertTrue(counterfactualResult.getOutputs().stream().anyMatch(o -> o.getName().equals("output1")));
NamedTypedValue value = counterfactualResult.getOutputs().iterator().next();
assertTrue(value.getValue().isUnit());
assertEquals(Double.class.getSimpleName(), value.getValue().toUnit().getType());
assertEquals(555.0, value.getValue().toUnit().getValue().asDouble());
}
use of org.junit.jupiter.api.function.ThrowingSupplier in project kolmafia by kolmafia.
the class StateCheckWrappersTest method postShutdownTest.
@Test
public void postShutdownTest() throws IllegalAccessException, InvocationTargetException {
initialize(new InitializeParams());
Assertions.assertDoesNotThrow((ThrowingSupplier<Object>) proxyServer.shutdown()::get, "Shutdown failed");
testWithAllMethods((methodName, requestCaller) -> {
// Post-shutdown requests should complete exceptionally with InvalidRequest
ExecutionException error = Assertions.assertThrows(ExecutionException.class, requestCaller.get()::get, methodName);
ResponseErrorException response = Assertions.assertInstanceOf(ResponseErrorException.class, error.getCause(), methodName);
Assertions.assertEquals("Server was shut down", response.getMessage(), methodName);
Assertions.assertEquals(ResponseErrorCode.InvalidRequest.getValue(), response.getResponseError().getCode(), methodName);
}, (methodName, notificationRunner) -> {
// Post-shutdown notifications should simply be ignored
notificationRunner.run();
pauser.pause(100);
Assertions.assertTrue(ignoredNotification(), methodName);
});
// State-related methods
// initialize(InitializeParams) acts like any other requests post-shutdown
ExecutionException error = Assertions.assertThrows(ExecutionException.class, proxyServer.initialize(new InitializeParams())::get);
ResponseErrorException response = Assertions.assertInstanceOf(ResponseErrorException.class, error.getCause());
Assertions.assertEquals("Server was shut down", response.getMessage());
Assertions.assertEquals(ResponseErrorCode.InvalidRequest.getValue(), response.getResponseError().getCode());
// initialized(InitializedParams) acts like any other notification post-shutdown
clearIgnoredNotification();
proxyServer.initialized(new InitializedParams());
pauser.pause(100);
Assertions.assertTrue(ignoredNotification());
// shutdown() acts like any other request post-shutdown
error = Assertions.assertThrows(ExecutionException.class, proxyServer.shutdown()::get);
response = Assertions.assertInstanceOf(ResponseErrorException.class, error.getCause());
Assertions.assertEquals("Server was shut down", response.getMessage());
Assertions.assertEquals(ResponseErrorCode.InvalidRequest.getValue(), response.getResponseError().getCode());
// exit() is always accepted
clearIgnoredNotification();
proxyServer.exit();
pauser.pause(100);
Assertions.assertFalse(ignoredNotification());
Assertions.assertTrue(trueServer.executor.isShutdown());
}
Aggregations