+ protected static String CONFIG_FILE = "model-loader.properties";\r
+\r
+ @Test\r
+ public void testWithMocks() throws Exception {\r
+\r
+ Properties configProperties = new Properties();\r
+ try {\r
+ configProperties.load(this.getClass().getClassLoader().getResourceAsStream(CONFIG_FILE));\r
+ } catch (IOException e) {\r
+ fail();\r
+ }\r
+ ModelLoaderConfig config = new ModelLoaderConfig(configProperties, null);\r
+ config.setModelVersion("11");\r
+\r
+ AaiRestClient mockRestClient = PowerMockito.mock(AaiRestClient.class);\r
+ PowerMockito.whenNew(AaiRestClient.class).withAnyArguments().thenReturn(mockRestClient);\r
+\r
+ // GET operation\r
+ OperationResult mockGetResp = PowerMockito.mock(OperationResult.class);\r
+\r
+ // @formatter:off\r
+ PowerMockito.when(mockGetResp.getResultCode())\r
+ .thenReturn(Response.Status.OK.getStatusCode())\r
+ .thenReturn(Response.Status.NOT_FOUND.getStatusCode())\r
+ .thenReturn(Response.Status.NOT_FOUND.getStatusCode())\r
+ .thenReturn(Response.Status.OK.getStatusCode());\r
+ // @formatter:on\r
+ PowerMockito.when(\r
+ mockRestClient.getResource(Mockito.anyString(), Mockito.anyString(), Mockito.any(MediaType.class)))\r
+ .thenReturn(mockGetResp);\r
+\r
+ // PUT operation\r
+ OperationResult mockPutResp = PowerMockito.mock(OperationResult.class);\r
+\r
+ PowerMockito.when(mockPutResp.getResultCode()).thenReturn(Response.Status.CREATED.getStatusCode());\r
+ PowerMockito.when(mockRestClient.putResource(Mockito.anyString(), Mockito.anyString(), Mockito.anyString(),\r
+ Mockito.any(MediaType.class))).thenReturn(mockPutResp);\r
+\r
+ // Example VNF Catalog with\r
+ VnfCatalogArtifactHandler vnfCAH = new VnfCatalogArtifactHandler(config);\r
+ String examplePath = "src/test/resources/imagedataexample.json";\r
+ /*\r
+ * byte[] encoded = Files.readAllBytes(Paths.get(examplePath)); List<Artifact> artifacts = new\r
+ * ArrayList<Artifact>(); artifacts.add(new VnfCatalogArtifact(new String(encoded, "utf-8")));\r
+ * \r
+ * assertTrue(vnfCAH.pushArtifacts(artifacts, "test", new ArrayList<Artifact>(), mockRestClient));\r
+ * \r
+ * // Only two of the VNF images should be pushed ArgumentCaptor<String> argument =\r
+ * ArgumentCaptor.forClass(String.class); AaiRestClient r = Mockito.verify(mockRestClient, Mockito.times(2));\r
+ * r.putResource(Mockito.anyString(), argument.capture(), Mockito.anyString(), Mockito.any(MediaType.class));\r
+ * assertTrue(argument.getAllValues().get(0).contains("3.16.9"));\r
+ * assertTrue(argument.getAllValues().get(0).contains("VM00"));\r
+ * assertTrue(argument.getAllValues().get(1).contains("3.16.1"));\r
+ * assertTrue(argument.getAllValues().get(1).contains("VM01"));\r
+ */\r