|
36 | 36 | import org.eclipse.digitaltwin.basyx.aasenvironment.AasEnvironment; |
37 | 37 | import org.eclipse.digitaltwin.basyx.aasenvironment.environmentloader.CompleteEnvironment; |
38 | 38 | import org.eclipse.digitaltwin.basyx.aasenvironment.environmentloader.CompleteEnvironment.EnvironmentType; |
| 39 | +import org.eclipse.digitaltwin.basyx.aasregistry.client.ApiException; |
| 40 | +import org.eclipse.digitaltwin.basyx.aasregistry.client.model.AssetAdministrationShellDescriptor; |
39 | 41 | import org.eclipse.digitaltwin.basyx.aasrepository.AasRepository; |
40 | 42 | import org.eclipse.digitaltwin.basyx.aasrepository.feature.registry.integration.AasRepositoryRegistryLink; |
| 43 | +import org.eclipse.digitaltwin.basyx.core.exceptions.RepositoryRegistryLinkException; |
41 | 44 | import org.eclipse.digitaltwin.basyx.core.pagination.PaginationInfo; |
42 | 45 | import org.eclipse.digitaltwin.basyx.submodelrepository.SubmodelRepository; |
43 | 46 | import org.eclipse.digitaltwin.basyx.submodelrepository.feature.registry.integration.SubmodelRepositoryRegistryLink; |
|
57 | 60 | */ |
58 | 61 | public class TestEnvironmentWithRegistryIntegration { |
59 | 62 |
|
60 | | - static final String FAULTY_AAS_PATH = "faulty_aas_reginteg.aasx"; |
| 63 | + static final String ENV_PATH = "testEnvironment.json"; |
61 | 64 |
|
62 | 65 | static ConfigurableApplicationContext appContext; |
63 | 66 |
|
@@ -92,14 +95,23 @@ public static void clearRegistries() throws Exception { |
92 | 95 | } |
93 | 96 |
|
94 | 97 | @Test |
95 | | - public void whenUploadDescriptorToRegistryFails_thenNoAasOrSmAreAddedToRepository() throws InvalidFormatException, DeserializationException, IOException { |
96 | | - CompleteEnvironment completeEnvironment = CompleteEnvironment.fromInputStream(getIsFromClasspath(FAULTY_AAS_PATH), EnvironmentType.AASX); |
| 98 | + public void whenUploadDescriptorToRegistryFails_thenNoAasOrSmAreAddedToRepository() throws InvalidFormatException, DeserializationException, IOException, ApiException { |
| 99 | + // simulate descriptor already being in registry |
| 100 | + aasRepositoryRegistryLink.getRegistryApi().postAssetAdministrationShellDescriptor(buildTestAasDescriptor()); |
97 | 101 |
|
98 | | - assertThrows(IllegalArgumentException.class, () -> aasEnvironment.loadEnvironment(completeEnvironment)); |
| 102 | + CompleteEnvironment completeEnvironment = CompleteEnvironment.fromInputStream(getIsFromClasspath(ENV_PATH), EnvironmentType.JSON); |
| 103 | + |
| 104 | + assertThrows(RepositoryRegistryLinkException.class, () -> aasEnvironment.loadEnvironment(completeEnvironment)); |
99 | 105 |
|
100 | 106 | assertRepositoriesAreEmpty(); |
101 | 107 | } |
102 | 108 |
|
| 109 | + private static AssetAdministrationShellDescriptor buildTestAasDescriptor() { |
| 110 | + AssetAdministrationShellDescriptor descriptor = new AssetAdministrationShellDescriptor(); |
| 111 | + descriptor.setId("https://acplt.test/Test_AssetAdministrationShell"); |
| 112 | + return descriptor; |
| 113 | + } |
| 114 | + |
103 | 115 | private static InputStream getIsFromClasspath(String fileName) throws IOException { |
104 | 116 | return new ClassPathResource(fileName).getInputStream(); |
105 | 117 | } |
|
0 commit comments