### Question:
AppcRunTasks { protected void getVserversForAppc(BuildingBlockExecution execution, GenericVnf vnf) throws RuntimeException { AAIResultWrapper aaiRW = aaiVnfResources.queryVnfWrapperById(vnf); if (aaiRW == null || aaiRW.getRelationships() == null || !aaiRW.getRelationships().isPresent()) { return; } Relationships relationships = aaiRW.getRelationships().get(); List<AAIResourceUri> vserverUris = relationships.getRelatedUris(Types.VSERVER); JSONArray vserverIds = new JSONArray(); JSONArray vserverSelfLinks = new JSONArray(); if (vserverUris != null) { for (AAIResourceUri j : vserverUris) { if (j != null) { if (j.getURIKeys() != null) { String vserverId = j.getURIKeys().get(AAIFluentTypeBuilder.Types.VSERVER.getUriParams().vserverId); vserverIds.put(vserverId); } aaiVnfResources.getVserver(j).ifPresent((vserver) -> { String vserverSelfLink = vserver.getVserverSelflink(); vserverSelfLinks.put(vserverSelfLink); }); } } } JSONObject vmidsArray = new JSONObject(); JSONObject vserveridsArray = new JSONObject(); vmidsArray.put("vmIds", vserverSelfLinks.toString()); vserveridsArray.put("vserverIds", vserverIds.toString()); logger.debug("vmidsArray is: {}", vmidsArray.toString()); logger.debug("vserveridsArray is: {}", vserveridsArray.toString()); execution.setVariable("vmIdList", vmidsArray.toString()); execution.setVariable("vserverIdList", vserveridsArray.toString()); }  void preProcessActivity(BuildingBlockExecution execution); void runAppcCommand(BuildingBlockExecution execution, Action action); static final String ROLLBACK_VNF_STOP; static final String ROLLBACK_VNF_LOCK; static final String ROLLBACK_QUIESCE_TRAFFIC; static final String CONTROLLER_TYPE_DEFAULT; static final String GENERIC_APPC_ERROR_CODE; }### Answer:
@Test public void getVserversForAppcTest() throws Exception { GenericVnf genericVnf = getTestGenericVnf(); final String aaiVnfJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiGenericVnfWithVservers.json"))); final String aaiVserverJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiVserverQueryResponse.json"))); AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(aaiVnfJson); ObjectMapper mapper = new ObjectMapper(); Vserver vserver = mapper.readValue(aaiVserverJson, Vserver.class); doReturn(aaiResultWrapper).when(aaiVnfResources).queryVnfWrapperById(genericVnf); doReturn(Optional.of(vserver)).when(aaiVnfResources).getVserver(any(AAIResourceUri.class)); appcRunTasks.getVserversForAppc(execution, genericVnf); String vserverIdList = execution.getVariable("vserverIdList"); String expectedVserverIdList = "{\"vserverIds\":\"[\\\"1b3f44e5-d96d-4aac-bd9a-310e8cfb0af5\\\",\\\"14551849-1e70-45cd-bc5d-a256d49548a2\\\",\\\"48bd7f11-408f-417c-b834-b41c1b98f7d7\\\"]\"}"; String vmIdList = execution.getVariable("vmIdList"); String expectedVmIdList = "{\"vmIds\":\"[\\\"http: assertEquals(vserverIdList, expectedVserverIdList); assertEquals(vmIdList, expectedVmIdList); }