diff options
author | Alexis de Talhouët <adetalhouet89@gmail.com> | 2018-08-29 15:05:53 -0400 |
---|---|---|
committer | Alexis de Talhouët <adetalhouet89@gmail.com> | 2018-08-29 15:06:50 -0400 |
commit | 8477931fc702262866d2d87c49cf5ec05032c267 (patch) | |
tree | 16ea6e12f2fbdc4df718787d4e3a298006205a68 /netbox-client/provider/src/test | |
parent | f1fcf4a707b91b078b5a8e03a1dd981f7c1ee263 (diff) |
Added support for external_key and resource_name
Change-Id: Ic44f24c3228e6ffcabb23b3866aaab01cb2f552b
Issue-ID: CCSDK-341
Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
Diffstat (limited to 'netbox-client/provider/src/test')
-rw-r--r-- | netbox-client/provider/src/test/java/org/onap/ccsdk/sli/adaptors/netbox/impl/NetboxClientImplTest.java | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/netbox-client/provider/src/test/java/org/onap/ccsdk/sli/adaptors/netbox/impl/NetboxClientImplTest.java b/netbox-client/provider/src/test/java/org/onap/ccsdk/sli/adaptors/netbox/impl/NetboxClientImplTest.java index 0f887a630..bc81f0b76 100644 --- a/netbox-client/provider/src/test/java/org/onap/ccsdk/sli/adaptors/netbox/impl/NetboxClientImplTest.java +++ b/netbox-client/provider/src/test/java/org/onap/ccsdk/sli/adaptors/netbox/impl/NetboxClientImplTest.java @@ -32,7 +32,9 @@ import static org.apache.http.HttpHeaders.CONTENT_TYPE; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import ch.qos.logback.classic.spi.ILoggingEvent; @@ -48,6 +50,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.UUID; +import javax.sql.rowset.CachedRowSet; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -89,7 +92,8 @@ public class NetboxClientImplTest { .of("service_instance_id", serviceInstanceId, "vf_module_id", vfModuleId, "prefix_id", "3", - "ip_address_id", "3" + "external_key", "3", + "resource_name", "3" ); private NetboxHttpClient httpClient; @@ -133,12 +137,18 @@ public class NetboxClientImplTest { public void unassignIpAddressTestNoParams() { QueryStatus status = netboxClient.unassignIpAddress(ImmutableMap.of(), svcLogicContext); Assert.assertEquals(QueryStatus.FAILURE, status); - verifyLogEntry("This method requires the parameters [service_instance_id,vf_module_id,ip_address_id], but no parameters were passed in"); + verifyLogEntry( + "This method requires the parameters [service_instance_id,external_key], but no parameters were passed in."); } @Test - public void unassignIpAddressFailedRequest() throws IOException { + public void unassignIpAddressFailedRequest() throws IOException, SQLException { doThrow(new IOException("Failed request")).when(httpClientMock).delete(anyString()); + + CachedRowSet crs = mock(CachedRowSet.class); + doReturn("3").when(crs).getString(eq("ip_address_id")); + doReturn(crs).when(dbLib).getData(anyString(), any(ArrayList.class), eq(null)); + QueryStatus status = netboxClientMock .unassignIpAddress(params, svcLogicContext); @@ -147,11 +157,15 @@ public class NetboxClientImplTest { } @Test - public void unassignIpAddressServerError() { + public void unassignIpAddressServerError() throws SQLException { String expectedUrl = "/api/ipam/ip-addresses/3/"; givenThat(delete(urlEqualTo(expectedUrl)).willReturn(serverError())); + CachedRowSet crs = mock(CachedRowSet.class); + doReturn("3").when(crs).getString(eq("ip_address_id")); + doReturn(crs).when(dbLib).getData(anyString(), any(ArrayList.class), eq(null)); + QueryStatus status = netboxClient.unassignIpAddress(params, svcLogicContext); Assert.assertEquals(QueryStatus.FAILURE, status); @@ -166,6 +180,10 @@ public class NetboxClientImplTest { String expectedUrl = "/api/ipam/ip-addresses/3/"; givenThat(delete(urlEqualTo(expectedUrl)).willReturn(created().withBody(response))); + CachedRowSet crs = mock(CachedRowSet.class); + doReturn("3").when(crs).getString(eq("ip_address_id")); + doReturn(crs).when(dbLib).getData(anyString(), any(ArrayList.class), eq(null)); + doThrow(new SQLException("Failed")).when(dbLib).writeData(anyString(), any(ArrayList.class), eq(null)); QueryStatus status = netboxClient.unassignIpAddress(params, svcLogicContext); @@ -181,6 +199,10 @@ public class NetboxClientImplTest { String expectedUrl = "/api/ipam/ip-addresses/3/"; givenThat(delete(urlEqualTo(expectedUrl)).willReturn(created().withBody(response))); + CachedRowSet crs = mock(CachedRowSet.class); + doReturn("3").when(crs).getString(eq("ip_address_id")); + doReturn(crs).when(dbLib).getData(anyString(), any(ArrayList.class), eq(null)); + QueryStatus status = netboxClient.unassignIpAddress(params, svcLogicContext); verify(deleteRequestedFor(urlEqualTo(expectedUrl)) @@ -197,7 +219,8 @@ public class NetboxClientImplTest { public void nextAvailableIpInPrefixTestNoId() { QueryStatus status = netboxClient.assignIpAddress(ImmutableMap.of(), svcLogicContext); Assert.assertEquals(QueryStatus.FAILURE, status); - verifyLogEntry("This method requires the parameters [service_instance_id,vf_module_id,prefix_id], but no parameters were passed in"); + verifyLogEntry( + "This method requires the parameters [service_instance_id,vf_module_id,prefix_id,resource_name,external_key], but no parameters were passed in."); } @Test |