|
32 | 32 | import java.io.File;
|
33 | 33 | import java.nio.file.Files;
|
34 | 34 | import java.nio.file.Paths;
|
| 35 | +import java.util.ArrayList; |
| 36 | +import java.util.Arrays; |
| 37 | +import java.util.List; |
35 | 38 |
|
36 | 39 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
37 | 40 | import static org.junit.jupiter.api.Assertions.assertNull;
|
| 41 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
38 | 42 | import static org.mockito.Mockito.any;
|
39 | 43 | import static org.mockito.Mockito.mockStatic;
|
40 | 44 |
|
@@ -97,6 +101,35 @@ void getProjectExplorerModelWithInvalidProjectFolder() {
|
97 | 101 | assertNull(result);
|
98 | 102 | }
|
99 | 103 |
|
| 104 | + @Test |
| 105 | + void getProjectIdentifiersWithArtifactList() { |
| 106 | + String resourcePath = "/synapse/resource.finder/test_project"; |
| 107 | + String projectPath = new File(DirectoryTreeBuilderTest.class.getResource(resourcePath).getPath()).getAbsolutePath(); |
| 108 | + connectorHolderMock.when(() -> ConnectorHolder.isValidConnector(any())).thenReturn(true); |
| 109 | + String apiPath = new File(DirectoryTreeBuilderTest.class.getResource(resourcePath + "/src/main/wso2mi/artifacts/apis/testApi.xml"). |
| 110 | + getPath()).getAbsolutePath(); |
| 111 | + String sequencePath = new File(DirectoryTreeBuilderTest.class.getResource(resourcePath + "/src/main/wso2mi/artifacts/sequences/testSequence1.xml") |
| 112 | + .getPath()).getAbsolutePath(); |
| 113 | + List<String> artifactIdentifierList = Arrays.asList("apis" + File.separator + "testApi", |
| 114 | + "sequences" + File.separator + "testSequence1"); |
| 115 | + List<String> result = DirectoryTreeBuilder.getProjectIdentifiers(new WorkspaceFolder(projectPath), |
| 116 | + Arrays.asList(apiPath, sequencePath)); |
| 117 | + connectorHolderMock.close(); |
| 118 | + |
| 119 | + assertEquals(artifactIdentifierList, result); |
| 120 | + } |
| 121 | + |
| 122 | + @Test |
| 123 | + void getProjectIdentifiersWithEmptyArtifactList() { |
| 124 | + String path = DirectoryTreeBuilderTest.class.getResource("/synapse/resource.finder/test_project").getPath(); |
| 125 | + String projectPath = new File(path).getAbsolutePath(); |
| 126 | + connectorHolderMock.when(() -> ConnectorHolder.isValidConnector(any())).thenReturn(true); |
| 127 | + List<String> result = DirectoryTreeBuilder.getProjectIdentifiers(new WorkspaceFolder(projectPath), new ArrayList<>()); |
| 128 | + connectorHolderMock.close(); |
| 129 | + |
| 130 | + assertTrue(result.isEmpty()); |
| 131 | + } |
| 132 | + |
100 | 133 | private static JsonObject sanitizeJson(JsonObject jsonObject) {
|
101 | 134 | JsonObject sanitizedJson = new JsonObject();
|
102 | 135 | for (String key : jsonObject.keySet()) {
|
|
0 commit comments