### Question:
ProcessHandler { public void createOrUpdateProcessHierarchyRelationship(String userId, ParentProcess parentProcess, String processGUID, String externalSourceName) throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { final String methodName = "createOrUpdateProcessHierarchyRelationship"; ProcessContainmentType processContainmentType = parentProcess.getProcessContainmentType(); InstanceProperties relationshipProperties = repositoryHelper.addEnumPropertyToInstance(serviceName, null, ProcessPropertiesMapper.CONTAINMENT_TYPE, processContainmentType.getOrdinal(), processContainmentType.getName(), processContainmentType.getDescription(), methodName); Optional<EntityDetail> parentProcessEntity = findProcessEntity(userId, parentProcess.getQualifiedName()); if (parentProcessEntity.isPresent()) { dataEngineCommonHandler.createOrUpdateExternalRelationship(userId, parentProcessEntity.get().getGUID(), processGUID, ProcessPropertiesMapper.PROCESS_HIERARCHY_TYPE_NAME, ProcessPropertiesMapper.PROCESS_TYPE_NAME, externalSourceName, relationshipProperties); } else { dataEngineCommonHandler.throwInvalidParameterException(DataEngineErrorCode.PROCESS_NOT_FOUND, methodName, "qualifiedName", parentProcess.getQualifiedName()); } } ProcessHandler(String serviceName, String serverName, InvalidParameterHandler invalidParameterHandler,
                          RepositoryHandler repositoryHandler, OMRSRepositoryHelper repositoryHelper, AssetHandler assetHandler,
                          DataEngineCommonHandler dataEngineCommonHandler, List<String> defaultZones, List<String> supportedZones); void setSecurityVerifier(OpenMetadataServerSecurityVerifier securityVerifier); String createProcess(String userId, Process process, String externalSourceName); void updateProcess(String userId, EntityDetail originalProcessEntity, Process updatedProcess); Optional<EntityDetail> findProcessEntity(String userId, String qualifiedName); void addProcessPortRelationship(String userId, String processGUID, String portGUID, String externalSourceName); void updateProcessStatus(String userId, String guid, InstanceStatus instanceStatus); Set<String> getPortsForProcess(String userId, String processGUID, String portTypeName); void createOrUpdateProcessHierarchyRelationship(String userId, ParentProcess parentProcess, String processGUID,
                                                           String externalSourceName);  }### Answer:
@Test void createOrUpdateProcessHierarchyRelationship() throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { ParentProcess parentProcess = new ParentProcess(); parentProcess.setProcessContainmentType(ProcessContainmentType.OWNED); parentProcess.setQualifiedName(PARENT_PROCESS_QUALIFIED_NAME); EntityDetail entityDetail = mock(EntityDetail.class); when(entityDetail.getGUID()).thenReturn(PARENT_GUID); Optional<EntityDetail> optionalOfMockedEntity = Optional.of(entityDetail); when(dataEngineCommonHandler.findEntity(USER, PARENT_PROCESS_QUALIFIED_NAME, ProcessPropertiesMapper.PROCESS_TYPE_NAME)).thenReturn(optionalOfMockedEntity); processHandler.createOrUpdateProcessHierarchyRelationship(USER, parentProcess, GUID, EXTERNAL_SOURCE_DE_QUALIFIED_NAME); verify(dataEngineCommonHandler, times(1)).createOrUpdateExternalRelationship(USER, PARENT_GUID, GUID, ProcessPropertiesMapper.PROCESS_HIERARCHY_TYPE_NAME, ProcessPropertiesMapper.PROCESS_TYPE_NAME, EXTERNAL_SOURCE_DE_QUALIFIED_NAME, null); }
@Test void createOrUpdateProcessHierarchyRelationship_parentProcessNotFound() throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { ParentProcess parentProcess = new ParentProcess(); parentProcess.setProcessContainmentType(ProcessContainmentType.OWNED); parentProcess.setQualifiedName(PARENT_PROCESS_QUALIFIED_NAME); when(dataEngineCommonHandler.findEntity(USER, PARENT_PROCESS_QUALIFIED_NAME, ProcessPropertiesMapper.PROCESS_TYPE_NAME)).thenReturn(Optional.empty()); processHandler.createOrUpdateProcessHierarchyRelationship(USER, parentProcess, GUID, EXTERNAL_SOURCE_DE_QUALIFIED_NAME); verify(dataEngineCommonHandler, times(1)).throwInvalidParameterException(DataEngineErrorCode.PROCESS_NOT_FOUND, "createOrUpdateProcessHierarchyRelationship", "qualifiedName", PARENT_PROCESS_QUALIFIED_NAME); }