use of org.kie.kogito.trusty.storage.api.model.decision.DMNModelMetadata in project kogito-apps by kiegroup.
the class DMNModelMetadataIdentifierTest method isBlank_ShouldReturnTrueForNullOrBlankStrings.
@ParameterizedTest
@MethodSource("provideParametersForModelIdCreator")
void isBlank_ShouldReturnTrueForNullOrBlankStrings(final String groupId, final String artifactId, final String version, final String name, final String namespace, final String expected) {
DMNModelMetadata modelIdentifier = new DMNModelMetadata(groupId, artifactId, version, "dmnVersion", name, namespace);
assertEquals(expected, modelIdentifier.getIdentifier());
}
use of org.kie.kogito.trusty.storage.api.model.decision.DMNModelMetadata 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.storage.api.model.decision.DMNModelMetadata in project kogito-apps by kiegroup.
the class TrustyServiceTest method whenAModelIsNotStoredAndRetrievedByIdThenExceptionIsThrown.
@Test
@SuppressWarnings("unchecked")
void whenAModelIsNotStoredAndRetrievedByIdThenExceptionIsThrown() {
DMNModelMetadata modelIdentifier = buildDmnModelIdentifier();
Storage storageMock = mock(Storage.class);
when(storageMock.containsKey(modelIdentifier.getIdentifier())).thenReturn(false);
when(trustyStorageServiceMock.getModelStorage(DMNModelWithMetadata.class)).thenReturn(storageMock);
assertThrows(IllegalArgumentException.class, () -> trustyService.getModelById(modelIdentifier, DMNModelWithMetadata.class));
}
use of org.kie.kogito.trusty.storage.api.model.decision.DMNModelMetadata in project kogito-apps by kiegroup.
the class TrustyServiceTest method givenAModelWhenStoreModelIsCalledMoreThanOnceForSameModelThenExceptionIsThrown.
@Test
@SuppressWarnings("unchecked")
void givenAModelWhenStoreModelIsCalledMoreThanOnceForSameModelThenExceptionIsThrown() {
String model = TEST_MODEL;
Storage storageMock = mock(Storage.class);
DMNModelWithMetadata dmnModelWithMetadata = buildDmnModel(model);
DMNModelMetadata modelIdentifier = dmnModelWithMetadata.getModelMetaData();
when(storageMock.containsKey(modelIdentifier.getIdentifier())).thenReturn(true);
when(storageMock.put(any(Object.class), any(Object.class))).thenReturn(model);
when(trustyStorageServiceMock.getModelStorage(DMNModelWithMetadata.class)).thenReturn(storageMock);
assertThrows(IllegalArgumentException.class, () -> trustyService.storeModel(dmnModelWithMetadata));
}
use of org.kie.kogito.trusty.storage.api.model.decision.DMNModelMetadata in project kogito-apps by kiegroup.
the class ModelEventConsumer method internalHandleDecisionModelEvent.
private void internalHandleDecisionModelEvent(DecisionModelEvent decisionModelEvent) {
DMNModelMetadata identifier = new DMNModelMetadata(decisionModelEvent.getGav().getGroupId(), decisionModelEvent.getGav().getArtifactId(), decisionModelEvent.getGav().getVersion(), decisionModelEvent.getModelMetadata().getSpecVersion(), decisionModelEvent.getName(), decisionModelEvent.getNamespace());
DMNModelWithMetadata dmnModelWithMetadata = new DMNModelWithMetadata(identifier, decisionModelEvent.getDefinition());
service.storeModel(dmnModelWithMetadata);
}
Aggregations