TackerManager implements SfcVnfManager, AutoCloseable { @Override public boolean deleteSf(ServiceFunction sf) { Token authToken = getToken(); if (authToken == null) { LOG.error("Failed to Acquire Authentication token!"); return false; } String vnfId = sf.getName().getValue(); WebResource webResource = client.resource(baseUri + ":" + tackerPort).path("/v1.0/vnfs/" + vnfId); ClientResponse response = webResource.type(javax.ws.rs.core.MediaType.APPLICATION_JSON) .header("X-Auth-Token", authToken.getId()) .header("X-Auth-Project-Id", authToken.getTenant().getName()) .delete(ClientResponse.class); if (response != null) { switch (response.getStatus()) { case 200: LOG.info("VNF:" + vnfId + " successfully deleted."); return true; case 404: LOG.debug("404 - Not Found:" + response.toString()); return false; case 405: LOG.debug("405 - Method not found: " + response.toString()); return false; default: TackerError error = GSON.fromJson(response.getEntity(String.class), TackerError.class); LOG.debug(error.toString()); break; } } return false; } private  TackerManager(TackerManagerBuilder builder); @Override boolean createSf(ServiceFunctionType sfType); @Override boolean deleteSf(ServiceFunction sf); @Override StatisticByTimestamp getSfStatistics(ServiceFunction sf); @Override void close(); static TackerManagerBuilder builder();  }
@Test public void deleteSfTest() { vnfs.add("Dpi"); ServiceFunction sf = new ServiceFunctionBuilder().setName(new SfName("Dpi")).setType(new SftTypeName("firewall")).build(); boolean result = tackerManager.deleteSf(sf); Assert.assertTrue(result); }
@Test public void deleteSfTestNotFound() { ServiceFunction sf = new ServiceFunctionBuilder().setName(new SfName("Nope")).setType(new SftTypeName("nope")).build(); boolean result = tackerManager.deleteSf(sf); Assert.assertFalse(result); }
@Test public void deleteSfTestBadRequest() { ServiceFunction sf = new ServiceFunctionBuilder().setName(new SfName(" ")).setType(new SftTypeName("error")).build(); Assert.assertFalse(tackerManager.deleteSf(sf)); sf = new ServiceFunctionBuilder().setName(new SfName("")).setType(new SftTypeName("error")).build(); Assert.assertFalse(tackerManager.deleteSf(sf)); }