### Question:
AAIDeleteTasks { public void deleteNetworkPolicies(BuildingBlockExecution execution) { try { String fqdns = execution.getVariable(contrailNetworkPolicyFqdnList); if (fqdns != null && !fqdns.isEmpty()) { String[] fqdnList = fqdns.split(","); int fqdnCount = fqdnList.length; if (fqdnCount > 0) { for (int i = 0; i < fqdnCount; i++) { String fqdn = fqdnList[i]; AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicies()); uri.queryParam(networkPolicyFqdnParam, fqdn); Optional<NetworkPolicies> oNetPolicies = aaiNetworkResources.getNetworkPolicies(uri); if (oNetPolicies.isPresent()) { NetworkPolicies networkPolicies = oNetPolicies.get(); List<NetworkPolicy> networkPolicyList = networkPolicies.getNetworkPolicy(); if (networkPolicyList != null && !networkPolicyList.isEmpty()) { NetworkPolicy networkPolicy = networkPolicyList.get(0); String networkPolicyId = networkPolicy.getNetworkPolicyId(); logger.debug("Deleting network-policy with network-policy-id {}", networkPolicyId); aaiNetworkResources.deleteNetworkPolicy(networkPolicyId); } } } } } } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } }  void deleteVfModule(BuildingBlockExecution execution); void deleteVnf(BuildingBlockExecution execution); void deleteServiceInstance(BuildingBlockExecution execution); void deleteNetwork(BuildingBlockExecution execution); void deleteCollection(BuildingBlockExecution execution); void deleteInstanceGroup(BuildingBlockExecution execution); void deleteVolumeGroup(BuildingBlockExecution execution); void deleteConfiguration(BuildingBlockExecution execution); void deleteInstanceGroupVnf(BuildingBlockExecution execution); void deleteNetworkPolicies(BuildingBlockExecution execution);  }### Answer:
@Test public void deleteNetworkPolicyNeedToDeleteAllTest() throws Exception { execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123,DEF456"); final String content0 = new String( Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPoliciesForDelete0.json"))); AAIResultWrapper aaiResultWrapper0 = new AAIResultWrapper(content0); NetworkPolicies networkPolicies0 = aaiResultWrapper0.asBean(NetworkPolicies.class).get(); final String content1 = new String( Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPoliciesForDelete1.json"))); AAIResultWrapper aaiResultWrapper1 = new AAIResultWrapper(content1); NetworkPolicies networkPolicies1 = aaiResultWrapper1.asBean(NetworkPolicies.class).get(); doReturn(Optional.of(networkPolicies0), Optional.of(networkPolicies1)).when(aaiNetworkResources) .getNetworkPolicies(any(AAIBaseResourceUri.class)); doNothing().when(aaiNetworkResources).deleteNetworkPolicy(any(String.class)); aaiDeleteTasks.deleteNetworkPolicies(execution); verify(aaiNetworkResources, times(2)).deleteNetworkPolicy(stringCaptor.capture()); assertEquals("testNetworkPolicyId0", stringCaptor.getAllValues().get(0)); assertEquals("testNetworkPolicyId1", stringCaptor.getAllValues().get(1)); }
@Test public void deleteNetworkPolicyNeedToDeleteNoneTest() throws Exception { execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123"); Optional<NetworkPolicies> networkPolicies = Optional.empty(); doReturn(networkPolicies).when(aaiNetworkResources).getNetworkPolicies(any(AAIBaseResourceUri.class)); aaiDeleteTasks.deleteNetworkPolicies(execution); verify(aaiNetworkResources, times(0)).deleteNetworkPolicy(any(String.class)); }
@Test public void deleteNetworkPolicyNoNetworkPoliciesTest() throws Exception { aaiDeleteTasks.deleteNetworkPolicies(execution); verify(aaiNetworkResources, times(0)).deleteNetworkPolicy(any(String.class)); }