### Question:
UnassignNetworkBB { public void checkRelationshipRelatedTo(BuildingBlockExecution execution, String relatedToValue) { try { L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID); AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network); Optional<org.onap.aai.domain.yang.L3Network> network = aaiResultWrapper.asBean(org.onap.aai.domain.yang.L3Network.class); if (networkBBUtils.isRelationshipRelatedToExists(network, relatedToValue)) { String msg = messageCannotPerformUnassign + relatedToValue; execution.setVariable("ErrorUnassignNetworkBB", msg); logger.error("ErrorUnassignNetworkBB: {}", msg); throw new UnassignNetworkException(msg); } } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } }  void checkRelationshipRelatedTo(BuildingBlockExecution execution, String relatedToValue); void getCloudSdncRegion(BuildingBlockExecution execution); void errorEncountered(BuildingBlockExecution execution);  }### Answer:
@Test public void checkRelationshipRelatedToTrueTest() throws Exception { expectedException.expect(BpmnError.class); network = setL3Network(); network.setNetworkId("testNetworkId1"); final String aaiResponse = new String( Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "unassignNetworkBB_queryAAIResponse_.json"))); AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(aaiResponse); Optional<org.onap.aai.domain.yang.L3Network> l3network = aaiResultWrapper.asBean(org.onap.aai.domain.yang.L3Network.class); doReturn(network).when(extractPojosForBB).extractByKey(execution, ResourceKey.NETWORK_ID); doReturn(aaiResultWrapper).when(aaiNetworkResources).queryNetworkWrapperById(network); doReturn(true).when(networkBBUtils).isRelationshipRelatedToExists(any(Optional.class), eq("vf-module")); unassignNetworkBB.checkRelationshipRelatedTo(execution, "vf-module"); assertThat(execution.getVariable("ErrorUnassignNetworkBB"), notNullValue()); }
@Test public void checkRelationshipRelatedToUnassignNetworkExceptionTest() throws Exception { String msg = "Cannot perform Unassign Network. Network is still related to vf-module"; expectedException.expect(BpmnError.class); doReturn(true).when(networkBBUtils).isRelationshipRelatedToExists(any(Optional.class), eq("vf-module")); unassignNetworkBB.checkRelationshipRelatedTo(execution, "vf-module"); assertEquals(execution.getVariable("ErrorUnassignNetworkBB"), msg); }