diff options
author | 2018-07-19 16:03:44 -0400 | |
---|---|---|
committer | 2018-07-19 16:08:20 -0400 | |
commit | 3bc6a702f2d3d8710c7aaa94cdc8c0ccf3deb759 (patch) | |
tree | 9703ebe15777acc73ad118520f6b1a219f60e107 /src/test/java/org/onap/crud/service | |
parent | 194adee686ebb90488f739f2c637f6cb3def94d5 (diff) |
Auto-resolve edge type
Auto-resolve edge type based on EdgeRules file.
Change-Id: Ic6de47f5172bc410efcdd5f08c1ea5c4f822610e
Issue-ID: AAI-1396
Signed-off-by: sblimkie <steven.blimkie@amdocs.com>
Diffstat (limited to 'src/test/java/org/onap/crud/service')
4 files changed, 34 insertions, 18 deletions
diff --git a/src/test/java/org/onap/crud/service/ChampDaoExceptionsTest.java b/src/test/java/org/onap/crud/service/ChampDaoExceptionsTest.java index 1f0a20b..a7479b5 100644 --- a/src/test/java/org/onap/crud/service/ChampDaoExceptionsTest.java +++ b/src/test/java/org/onap/crud/service/ChampDaoExceptionsTest.java @@ -229,7 +229,7 @@ public class ChampDaoExceptionsTest { buildChampDao(); try { - champDao.getEdge(idNotExists, type, txId); + champDao.getEdge(idNotExists, txId); } catch (CrudException e) { assertEquals(404, e.getHttpStatus().getStatusCode()); assertThat(e.getMessage(), containsString(failureCauseForGetEdge)); @@ -250,7 +250,7 @@ public class ChampDaoExceptionsTest { // Type not matches try { - champDao.getEdge(id, "", txId); + champDao.getEdge(id, txId); } catch (CrudException e) { assertEquals(404, e.getHttpStatus().getStatusCode()); assertThat(e.getMessage(), containsString(failureCauseForGetEdgeTypeNotMatches)); @@ -332,7 +332,7 @@ public class ChampDaoExceptionsTest { buildChampDao(); try { - champDao.getVertexEdges(idNotExists, queryParams); + champDao.getVertexEdges(idNotExists, queryParams, null); } catch (CrudException e) { assertEquals(404, e.getHttpStatus().getStatusCode()); assertThat(e.getMessage(), containsString(failureCauseForGetVertexEdges)); @@ -509,13 +509,13 @@ public class ChampDaoExceptionsTest { buildChampDao(); try { - champDao.deleteEdge(id, type); + champDao.deleteEdge(id); } catch (CrudException e) { assertEquals(400, e.getHttpStatus().getStatusCode()); assertThat(e.getMessage(), containsString(failureCauseFordeleteEdge)); } try { - champDao.deleteEdge(id, type, txId); + champDao.deleteEdge(id, txId); } catch (CrudException e) { assertEquals(400, e.getHttpStatus().getStatusCode()); assertThat(e.getMessage(), containsString(failureCauseFordeleteEdge)); diff --git a/src/test/java/org/onap/crud/service/ChampDaoMockTest.java b/src/test/java/org/onap/crud/service/ChampDaoMockTest.java index 75d5bfd..dadf81a 100644 --- a/src/test/java/org/onap/crud/service/ChampDaoMockTest.java +++ b/src/test/java/org/onap/crud/service/ChampDaoMockTest.java @@ -269,11 +269,13 @@ public class ChampDaoMockTest { mockGetVertex("50bdab41-ad1c-4d00-952c-a0aa5d827811", "?transactionId=", "vserver"); mockGetVertices(queryParamsVertices, "pserver"); mockGetVertices(queryParamsVerticesV13, "pserver"); - mockGetVertexEdges("872dd5df-0be9-4167-95e9-2cf4b21165ed", queryParamsVertex, "tosca.relationships.HostedOn"); - mockGetVertexEdges("872dd5df-0be9-4167-95e9-2cf4b21165ed", queryParamsVertexV13, + mockGetVertexEdges("872dd5df-0be9-4167-95e9-2cf4b21165ed", queryParamsVertex, null, "tosca.relationships.HostedOn"); + mockGetVertexEdges("872dd5df-0be9-4167-95e9-2cf4b21165ed", queryParamsVertexV13, null, "tosca.relationships.HostedOn"); - mockGetVertexEdges("50bdab41-ad1c-4d00-952c-a0aa5d827811", emptyQueryParams, "tosca.relationships.HostedOn"); - mockGetVertexEdges("1d326bc7-b985-492b-9604-0d5d1f06f908", emptyQueryParams, "tosca.relationships.HostedOn"); + mockGetVertexEdges("50bdab41-ad1c-4d00-952c-a0aa5d827811", emptyQueryParams, null, "tosca.relationships.HostedOn"); + mockGetVertexEdges("1d326bc7-b985-492b-9604-0d5d1f06f908", emptyQueryParams, null, "tosca.relationships.HostedOn"); + mockGetVertexEdges("50bdab41-ad1c-4d00-952c-a0aa5d827811", emptyQueryParams, "?transactionId=", "tosca.relationships.HostedOn"); + mockGetVertexEdges("1d326bc7-b985-492b-9604-0d5d1f06f908", emptyQueryParams, "?transactionId=", "tosca.relationships.HostedOn"); mockGetEdges("?", "tosca.relationships.HostedOn"); mockGetEdge("50bdab41-ad1c-4d00-952c-a0aa5d827811", "?transactionId=", "tosca.relationships.HostedOn"); mockGetEdge("872dd5df-0be9-4167-95e9-2cf4b21165ed", emptyQueryParams, "tosca.relationships.HostedOn"); @@ -372,17 +374,24 @@ public class ChampDaoMockTest { .thenReturn(operationResult); } - public void mockGetVertexEdges(String id, Map<String, String> queryParams, String type) { + public void mockGetVertexEdges(String id, Map<String, String> queryParams, String txId, String type) { String edgeResponse = champEdge.replace("edgeType", type); OperationResult operationResult = new OperationResult(); List<String> edgeResponselist = new ArrayList<>(); edgeResponselist.add(edgeResponse); operationResult.setResult(edgeResponselist.toString()); operationResult.setResultCode(200); + String baseUrl = BASE_OBJECT_URL + "/" + RELATIONSHIP_SUB_URL + "/" + id; + String url; + + if (txId != null) { + url = baseUrl + txId; + } + else { + url = appendQueryParams(baseUrl, queryParams).toString(); + } - StringBuilder url = appendQueryParams(BASE_OBJECT_URL + "/" + RELATIONSHIP_SUB_URL + "/" + id, queryParams); - - when(restClientMock.get(url.toString(), createHeaders(), MediaType.APPLICATION_JSON_TYPE)) + when(restClientMock.get(url, createHeaders(), MediaType.APPLICATION_JSON_TYPE)) .thenReturn(operationResult); } diff --git a/src/test/java/org/onap/crud/service/CrudRestServiceTest.java b/src/test/java/org/onap/crud/service/CrudRestServiceTest.java index d8be704..1098284 100644 --- a/src/test/java/org/onap/crud/service/CrudRestServiceTest.java +++ b/src/test/java/org/onap/crud/service/CrudRestServiceTest.java @@ -335,7 +335,8 @@ public class CrudRestServiceTest { response = mockService.addBulk(payloadStr, "v9", "", "services/inventory/v9", new TestHeaders(), null, new TestRequest()); - System.out.println("Bulk Response: " + response.getStatus() + "\n" + response.getEntity().toString()); + System.out.println("Bulk Response: " + response); + System.out.println("Response Entity: " + response.getEntity().toString()); assertTrue(response.getStatus() == 200); } diff --git a/src/test/java/org/onap/crud/service/TestDao.java b/src/test/java/org/onap/crud/service/TestDao.java index 20cd04a..4f1d34e 100644 --- a/src/test/java/org/onap/crud/service/TestDao.java +++ b/src/test/java/org/onap/crud/service/TestDao.java @@ -84,7 +84,7 @@ public class TestDao implements GraphDao { } @Override - public List<Edge> getVertexEdges(String id, Map<String, String> queryParams) throws CrudException { + public List<Edge> getVertexEdges(String id, Map<String, String> queryParams, String txId) throws CrudException { List<Edge> list = new ArrayList<Edge>(); list.add(Edge.fromJson(champEdge)); return list; @@ -159,7 +159,7 @@ public class TestDao implements GraphDao { } @Override - public void deleteEdge(String id, String type) throws CrudException { + public void deleteEdge(String id) throws CrudException { } @@ -217,13 +217,13 @@ public class TestDao implements GraphDao { } @Override - public void deleteEdge(String id, String type, String txId) throws CrudException { + public void deleteEdge(String id, String txId) throws CrudException { // TODO Auto-generated method stub } @Override - public Edge getEdge(String id, String type, String txId) throws CrudException { + public Edge getEdge(String id, String txId) throws CrudException { return Edge.fromJson(champEdge); } @@ -232,4 +232,10 @@ public class TestDao implements GraphDao { headers.add("etag", "test123"); return headers; } + + @Override + public Edge getEdge(String id) throws CrudException { + // TODO Auto-generated method stub + return null; + } }
\ No newline at end of file |