Skip to content

Commit

Permalink
Resolves conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: Mohammad Ghazanfar Ali Danish <[email protected]>
  • Loading branch information
mdanish98 committed Oct 24, 2024
2 parents ccd3229 + d4a4fed commit b7fdb62
Show file tree
Hide file tree
Showing 90 changed files with 1,137 additions and 736 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@
<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>basyx.aasdiscoveryservice-backend</artifactId>
</dependency>

</dependency>
<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>basyx.backend.inmemory.core</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>basyx.aasdiscoveryservice-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend.AasDiscoveryBackendProvider;
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend.AasDiscoveryDocument;
import org.eclipse.digitaltwin.basyx.common.backend.inmemory.core.InMemoryCrudRepository;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Component;
Expand All @@ -41,7 +42,7 @@
@Component
public class AasDiscoveryInMemoryBackendProvider implements AasDiscoveryBackendProvider {

private AasDiscoveryInMemoryCrudRepository repository = new AasDiscoveryInMemoryCrudRepository();
private CrudRepository<AasDiscoveryDocument, String> repository = new InMemoryCrudRepository<AasDiscoveryDocument>(AasDiscoveryDocument::getShellIdentifier);

@Override
public CrudRepository<AasDiscoveryDocument, String> getCrudRepository() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ public abstract class AasDiscoveryServiceSuite {

protected abstract AasDiscoveryService getAasDiscoveryService();

private final PaginationInfo noLimitPaginationInfo = new PaginationInfo(0, "");

@Test
public void getAllAssetAdministrationShellIdsByAssetLink() {
AasDiscoveryService discoveryService = getAasDiscoveryService();
Expand All @@ -74,7 +72,7 @@ public void getAllAssetAdministrationShellIdsByAssetLink() {
new AssetLink("DummyAssetName2", "DummyAsset_2_Value")
));

List<String> actualResult = discoveryService.getAllAssetAdministrationShellIdsByAssetLink(noLimitPaginationInfo, assetIds)
List<String> actualResult = discoveryService.getAllAssetAdministrationShellIdsByAssetLink(PaginationInfo.NO_LIMIT, assetIds)
.getResult();

assertEquals(expectedResult.size(), actualResult.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ public class AasEnvironmentLoaderTest {
protected static final String TEST_ENVIRONMENT_SHELLS_ONLY_JSON = "/org/eclipse/digitaltwin/basyx/aasenvironment/environment_with_shells_only.json";
protected static final String TEST_ENVIRONMENT_SUBMODELS_ONLY_JSON = "/org/eclipse/digitaltwin/basyx/aasenvironment/environment_with_submodels_only.json";

protected static final PaginationInfo ALL = new PaginationInfo(0, null);

protected AasRepository aasRepository;
protected SubmodelRepository submodelRepository;
protected ConceptDescriptionRepository conceptDescriptionRepository;
Expand All @@ -96,9 +94,9 @@ protected void loadRepositories(List<String> pathsToLoad) throws IOException, De
public void testWithResourceFile_AllElementsAreDeployed() throws InvalidFormatException, IOException, DeserializationException {
loadRepositories(List.of(TEST_ENVIRONMENT_JSON));

Assert.assertEquals(2, aasRepository.getAllAas(ALL).getResult().size());
Assert.assertEquals(2, submodelRepository.getAllSubmodels(ALL).getResult().size());
Assert.assertEquals(2, conceptDescriptionRepository.getAllConceptDescriptions(ALL).getResult().size());
Assert.assertEquals(2, aasRepository.getAllAas(PaginationInfo.NO_LIMIT).getResult().size());
Assert.assertEquals(2, submodelRepository.getAllSubmodels(PaginationInfo.NO_LIMIT).getResult().size());
Assert.assertEquals(2, conceptDescriptionRepository.getAllConceptDescriptions(PaginationInfo.NO_LIMIT).getResult().size());
}

@Test
Expand All @@ -112,9 +110,9 @@ public void testDeployedTwiceNoVersion_AllDeployedButNotOverriden() throws Inval
Mockito.verify(submodelRepository, Mockito.times(2)).createSubmodel(Mockito.any());
Mockito.verify(submodelRepository, Mockito.times(0)).updateSubmodel(Mockito.anyString(), Mockito.any());

Assert.assertEquals(2, aasRepository.getAllAas(ALL).getResult().size());
Assert.assertEquals(2, submodelRepository.getAllSubmodels(ALL).getResult().size());
Assert.assertEquals(2, conceptDescriptionRepository.getAllConceptDescriptions(ALL).getResult().size());
Assert.assertEquals(2, aasRepository.getAllAas(PaginationInfo.NO_LIMIT).getResult().size());
Assert.assertEquals(2, submodelRepository.getAllSubmodels(PaginationInfo.NO_LIMIT).getResult().size());
Assert.assertEquals(2, conceptDescriptionRepository.getAllConceptDescriptions(PaginationInfo.NO_LIMIT).getResult().size());
}

@Test
Expand All @@ -128,9 +126,9 @@ public void testDeployedTwiceWithSameVersion_AllDeployedButNotOverriden() throws
Mockito.verify(submodelRepository, Mockito.times(2)).createSubmodel(Mockito.any());
Mockito.verify(submodelRepository, Mockito.times(0)).updateSubmodel(Mockito.anyString(), Mockito.any());

Assert.assertEquals(2, aasRepository.getAllAas(ALL).getResult().size());
Assert.assertEquals(2, submodelRepository.getAllSubmodels(ALL).getResult().size());
Assert.assertEquals(2, conceptDescriptionRepository.getAllConceptDescriptions(ALL).getResult().size());
Assert.assertEquals(2, aasRepository.getAllAas(PaginationInfo.NO_LIMIT).getResult().size());
Assert.assertEquals(2, submodelRepository.getAllSubmodels(PaginationInfo.NO_LIMIT).getResult().size());
Assert.assertEquals(2, conceptDescriptionRepository.getAllConceptDescriptions(PaginationInfo.NO_LIMIT).getResult().size());
}

@Test
Expand All @@ -144,9 +142,9 @@ public void testDeployedTwiceNewRevision_ElementsAreOverriden() throws InvalidFo
Mockito.verify(submodelRepository, Mockito.times(2)).createSubmodel(Mockito.any());
Mockito.verify(submodelRepository, Mockito.times(1)).updateSubmodel(Mockito.anyString(), Mockito.any());

Assert.assertEquals(2, aasRepository.getAllAas(ALL).getResult().size());
Assert.assertEquals(2, submodelRepository.getAllSubmodels(ALL).getResult().size());
Assert.assertEquals(2, conceptDescriptionRepository.getAllConceptDescriptions(ALL).getResult().size());
Assert.assertEquals(2, aasRepository.getAllAas(PaginationInfo.NO_LIMIT).getResult().size());
Assert.assertEquals(2, submodelRepository.getAllSubmodels(PaginationInfo.NO_LIMIT).getResult().size());
Assert.assertEquals(2, conceptDescriptionRepository.getAllConceptDescriptions(PaginationInfo.NO_LIMIT).getResult().size());
}

@Test
Expand All @@ -168,17 +166,17 @@ public void testWithResourceFile_NoExceptionsWhenReuploadAfterElementsAreRemoved

loadRepositoriesWithEnvironment(List.of(TEST_ENVIRONMENT_JSON), envLoader);

Assert.assertEquals(2, aasRepository.getAllAas(ALL).getResult().size());
Assert.assertEquals(2, submodelRepository.getAllSubmodels(ALL).getResult().size());
Assert.assertEquals(2, conceptDescriptionRepository.getAllConceptDescriptions(ALL).getResult().size());
Assert.assertEquals(2, aasRepository.getAllAas(PaginationInfo.NO_LIMIT).getResult().size());
Assert.assertEquals(2, submodelRepository.getAllSubmodels(PaginationInfo.NO_LIMIT).getResult().size());
Assert.assertEquals(2, conceptDescriptionRepository.getAllConceptDescriptions(PaginationInfo.NO_LIMIT).getResult().size());

deleteElementsFromRepos();

loadRepositoriesWithEnvironment(List.of(TEST_ENVIRONMENT_JSON), envLoader);

Assert.assertEquals(2, aasRepository.getAllAas(ALL).getResult().size());
Assert.assertEquals(2, submodelRepository.getAllSubmodels(ALL).getResult().size());
Assert.assertEquals(2, conceptDescriptionRepository.getAllConceptDescriptions(ALL).getResult().size());
Assert.assertEquals(2, aasRepository.getAllAas(PaginationInfo.NO_LIMIT).getResult().size());
Assert.assertEquals(2, submodelRepository.getAllSubmodels(PaginationInfo.NO_LIMIT).getResult().size());
Assert.assertEquals(2, conceptDescriptionRepository.getAllConceptDescriptions(PaginationInfo.NO_LIMIT).getResult().size());
}

@Test
Expand All @@ -187,9 +185,9 @@ public void testWithResourceFile_ExceptionIsThrownWhenReuploadWithExistingElemen

loadRepositoriesWithEnvironment(List.of(TEST_ENVIRONMENT_JSON), envLoader);

Assert.assertEquals(2, aasRepository.getAllAas(ALL).getResult().size());
Assert.assertEquals(2, submodelRepository.getAllSubmodels(ALL).getResult().size());
Assert.assertEquals(2, conceptDescriptionRepository.getAllConceptDescriptions(ALL).getResult().size());
Assert.assertEquals(2, aasRepository.getAllAas(PaginationInfo.NO_LIMIT).getResult().size());
Assert.assertEquals(2, submodelRepository.getAllSubmodels(PaginationInfo.NO_LIMIT).getResult().size());
Assert.assertEquals(2, conceptDescriptionRepository.getAllConceptDescriptions(PaginationInfo.NO_LIMIT).getResult().size());

String expectedMsg = new CollidingIdentifierException("aas1").getMessage();
Assert.assertThrows(expectedMsg, CollidingIdentifierException.class, () -> loadRepositoriesWithEnvironment(List.of(TEST_ENVIRONMENT_JSON), envLoader));
Expand All @@ -204,13 +202,13 @@ private void loadRepositoriesWithEnvironment(List<String> pathsToLoad, AasEnviro
}

private void deleteElementsFromRepos() {
aasRepository.getAllAas(ALL).getResult().stream().forEach(aas -> aasRepository.deleteAas(aas.getId()));
submodelRepository.getAllSubmodels(ALL).getResult().stream().forEach(sm -> submodelRepository.deleteSubmodel(sm.getId()));
conceptDescriptionRepository.getAllConceptDescriptions(ALL).getResult().stream().forEach(cd -> conceptDescriptionRepository.deleteConceptDescription(cd.getId()));
aasRepository.getAllAas(PaginationInfo.NO_LIMIT).getResult().stream().forEach(aas -> aasRepository.deleteAas(aas.getId()));
submodelRepository.getAllSubmodels(PaginationInfo.NO_LIMIT).getResult().stream().forEach(sm -> submodelRepository.deleteSubmodel(sm.getId()));
conceptDescriptionRepository.getAllConceptDescriptions(PaginationInfo.NO_LIMIT).getResult().stream().forEach(cd -> conceptDescriptionRepository.deleteConceptDescription(cd.getId()));

Assert.assertEquals(0, aasRepository.getAllAas(ALL).getResult().size());
Assert.assertEquals(0, submodelRepository.getAllSubmodels(ALL).getResult().size());
Assert.assertEquals(0, conceptDescriptionRepository.getAllConceptDescriptions(ALL).getResult().size());
Assert.assertEquals(0, aasRepository.getAllAas(PaginationInfo.NO_LIMIT).getResult().size());
Assert.assertEquals(0, submodelRepository.getAllSubmodels(PaginationInfo.NO_LIMIT).getResult().size());
Assert.assertEquals(0, conceptDescriptionRepository.getAllConceptDescriptions(PaginationInfo.NO_LIMIT).getResult().size());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.DeserializationException;
import org.eclipse.digitaltwin.basyx.aasenvironment.base.DefaultAASEnvironment;
import org.eclipse.digitaltwin.basyx.aasenvironment.preconfiguration.AasEnvironmentPreconfigurationLoader;
import org.eclipse.digitaltwin.basyx.core.pagination.PaginationInfo;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
Expand All @@ -52,9 +53,9 @@ protected void loadRepositories(List<String> pathsToLoad) throws IOException, In
@Test
public void testWithEmptyResource_NoElementsAreDeployed() throws InvalidFormatException, IOException, DeserializationException {
loadRepositories(List.of());
Assert.assertTrue(aasRepository.getAllAas(ALL).getResult().isEmpty());
Assert.assertTrue(submodelRepository.getAllSubmodels(ALL).getResult().isEmpty());
Assert.assertTrue(conceptDescriptionRepository.getAllConceptDescriptions(ALL).getResult().isEmpty());
Assert.assertTrue(aasRepository.getAllAas(PaginationInfo.NO_LIMIT).getResult().isEmpty());
Assert.assertTrue(submodelRepository.getAllSubmodels(PaginationInfo.NO_LIMIT).getResult().isEmpty());
Assert.assertTrue(conceptDescriptionRepository.getAllConceptDescriptions(PaginationInfo.NO_LIMIT).getResult().isEmpty());

Mockito.verify(aasRepository, Mockito.never()).createAas(Mockito.any());
Mockito.verify(aasRepository, Mockito.never()).updateAas(Mockito.anyString(), Mockito.any());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@

public class TestAASEnvironmentSerialization {

private static final PaginationInfo NO_LIMIT_PAGINATION_INFO = new PaginationInfo(0, "");
public static final String AAS_TECHNICAL_DATA_ID = "shell001";
public static final String AAS_OPERATIONAL_DATA_ID = "shell002";
public static final String SUBMODEL_TECHNICAL_DATA_ID = "7A7104BDAB57E184";
Expand Down Expand Up @@ -266,9 +265,9 @@ private static List<String> retrieveConceptDescriptionIds(Environment aasEnviron
}

private void validateRepositoriesState() {
assertTrue(aasRepository.getAllAas(NO_LIMIT_PAGINATION_INFO).getResult().containsAll(createDummyShells()));
assertTrue(submodelRepository.getAllSubmodels(NO_LIMIT_PAGINATION_INFO).getResult().containsAll(createDummySubmodels()));
assertTrue(conceptDescriptionRepository.getAllConceptDescriptions(NO_LIMIT_PAGINATION_INFO).getResult().containsAll(createDummyConceptDescriptions()));
assertTrue(aasRepository.getAllAas(PaginationInfo.NO_LIMIT).getResult().containsAll(createDummyShells()));
assertTrue(submodelRepository.getAllSubmodels(PaginationInfo.NO_LIMIT).getResult().containsAll(createDummySubmodels()));
assertTrue(conceptDescriptionRepository.getAllConceptDescriptions(PaginationInfo.NO_LIMIT).getResult().containsAll(createDummyConceptDescriptions()));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
*/
public class TestAuthorizedAasEnvironmentSerialization {

private static final PaginationInfo NO_LIMIT_PAGINATION_INFO = new PaginationInfo(0, null);
private static String authenticaltionServerTokenEndpoint = "http://localhost:9096/realms/BaSyx/protocol/openid-connect/token";
private static String clientId = "basyx-client-api";
private static AccessTokenProvider tokenProvider;
Expand Down Expand Up @@ -101,9 +100,9 @@ public static void tearDown() {
public void reset() throws FileNotFoundException, IOException {
configureSecurityContext();

Collection<AssetAdministrationShell> assetAdministrationShells = aasRepo.getAllAas(NO_LIMIT_PAGINATION_INFO).getResult();
Collection<Submodel> submodels = submodelRepo.getAllSubmodels(NO_LIMIT_PAGINATION_INFO).getResult();
Collection<ConceptDescription> conceptDescriptions = conceptDescriptionRepo.getAllConceptDescriptions(NO_LIMIT_PAGINATION_INFO).getResult();
Collection<AssetAdministrationShell> assetAdministrationShells = aasRepo.getAllAas(PaginationInfo.NO_LIMIT).getResult();
Collection<Submodel> submodels = submodelRepo.getAllSubmodels(PaginationInfo.NO_LIMIT).getResult();
Collection<ConceptDescription> conceptDescriptions = conceptDescriptionRepo.getAllConceptDescriptions(PaginationInfo.NO_LIMIT).getResult();

assetAdministrationShells.stream().forEach(aas -> aasRepo.deleteAas(aas.getId()));
submodels.stream().forEach(sm -> submodelRepo.deleteSubmodel(sm.getId()));
Expand Down
Loading

0 comments on commit b7fdb62

Please sign in to comment.