use of org.kie.kogito.trusty.service.common.mocks.StorageImplMock in project kogito-apps by kiegroup.
the class TrustyServiceTest method givenAModelWhenAModelIsStoredAndRetrievedByIdThenTheOriginalObjectIsReturned.
@Test
@SuppressWarnings("unchecked")
void givenAModelWhenAModelIsStoredAndRetrievedByIdThenTheOriginalObjectIsReturned() {
String model = TEST_MODEL;
Storage storageMock = new StorageImplMock(String.class);
when(trustyStorageServiceMock.getModelStorage(DMNModelWithMetadata.class)).thenReturn(storageMock);
DMNModelWithMetadata dmnModelWithMetadata = buildDmnModel(model);
DMNModelMetadata modelIdentifier = dmnModelWithMetadata.getModelMetaData();
trustyService.storeModel(buildDmnModel(model));
DMNModelWithMetadata result = trustyService.getModelById(modelIdentifier, DMNModelWithMetadata.class);
assertEquals(model, result.getModel());
}
use of org.kie.kogito.trusty.service.common.mocks.StorageImplMock in project kogito-apps by kiegroup.
the class TrustyServiceTest method givenADecisionWhenADecisionIsStoredAndRetrievedByIdThenTheOriginalObjectIsReturned.
@Test
@SuppressWarnings("unchecked")
void givenADecisionWhenADecisionIsStoredAndRetrievedByIdThenTheOriginalObjectIsReturned() {
Decision decision = new Decision();
decision.setExecutionId(TEST_EXECUTION_ID);
@SuppressWarnings("unchecked") Storage storageMock = new StorageImplMock(Decision.class);
when(trustyStorageServiceMock.getDecisionsStorage()).thenReturn(storageMock);
trustyService.storeDecision(TEST_EXECUTION_ID, decision);
Decision result = trustyService.getDecisionById(TEST_EXECUTION_ID);
assertEquals(TEST_EXECUTION_ID, result.getExecutionId());
}
use of org.kie.kogito.trusty.service.common.mocks.StorageImplMock in project kogito-apps by kiegroup.
the class TrustyServiceTest method givenAnExplainabilityResultWhenAnExplainabilityResultIsStoredAndRetrievedByIdThenTheOriginalObjectIsReturned.
@Test
void givenAnExplainabilityResultWhenAnExplainabilityResultIsStoredAndRetrievedByIdThenTheOriginalObjectIsReturned() {
LIMEExplainabilityResult result = new LIMEExplainabilityResult(TEST_EXECUTION_ID, ExplainabilityStatus.SUCCEEDED, null, Collections.emptyList());
Storage<String, LIMEExplainabilityResult> storageMock = new StorageImplMock<>(String.class);
when(trustyStorageServiceMock.getLIMEResultStorage()).thenReturn(storageMock);
trustyService.storeExplainabilityResult(TEST_EXECUTION_ID, result);
// The mocked stream needs to be recreated for subsequent invocations
when(explanationHandlers.stream()).thenReturn(Stream.of(limeExplainerServiceHandler, counterfactualExplainerServiceHandler));
assertEquals(result, trustyService.getExplainabilityResultById(TEST_EXECUTION_ID, LIMEExplainabilityResult.class));
}
Aggregations