### Question:
DataEngineRegistrationHandler { public String getExternalDataEngineByQualifiedName(String userId, String qualifiedName) throws InvalidParameterException, UserNotAuthorizedException, PropertyServerException { final String methodName = "getExternalDataEngineByQualifiedName"; qualifiedName = repositoryHelper.getExactMatchRegex(qualifiedName); invalidParameterHandler.validateUserId(userId, methodName); invalidParameterHandler.validateName(qualifiedName, DataEnginePropertiesMapper.QUALIFIED_NAME_PROPERTY_NAME, methodName); InstanceProperties properties = repositoryHelper.addStringPropertyToInstance(serviceName, null, DataEnginePropertiesMapper.QUALIFIED_NAME_PROPERTY_NAME, qualifiedName, methodName); TypeDef entityTypeDef = repositoryHelper.getTypeDefByName(userId, DataEnginePropertiesMapper.SOFTWARE_SERVER_CAPABILITY_TYPE_NAME); EntityDetail retrievedEntity = repositoryHandler.getUniqueEntityByName(userId, qualifiedName, DataEnginePropertiesMapper.QUALIFIED_NAME_PROPERTY_NAME, properties, entityTypeDef.getGUID(), entityTypeDef.getName(), methodName); if (retrievedEntity == null) { return null; } return retrievedEntity.getGUID(); } DataEngineRegistrationHandler(String serviceName, String serverName,
                                         InvalidParameterHandler invalidParameterHandler,
                                         RepositoryHandler repositoryHandler,
                                         OMRSRepositoryHelper repositoryHelper); String createOrUpdateExternalDataEngine(String userId, SoftwareServerCapability softwareServerCapability); String getExternalDataEngineByQualifiedName(String userId, String qualifiedName);  }### Answer:
@Test void getExternalDataEngineByQualifiedName() throws UserNotAuthorizedException, PropertyServerException, InvalidParameterException { String methodName = "getExternalDataEngineByQualifiedName"; EntityDetail entityDetail = Mockito.mock(EntityDetail.class); when(entityDetail.getGUID()).thenReturn(GUID); when(repositoryHandler.getUniqueEntityByName(USER, QUALIFIED_NAME, DataEnginePropertiesMapper.QUALIFIED_NAME_PROPERTY_NAME, null, DataEnginePropertiesMapper.SOFTWARE_SERVER_CAPABILITY_TYPE_GUID, DataEnginePropertiesMapper.SOFTWARE_SERVER_CAPABILITY_TYPE_NAME, methodName)).thenReturn(entityDetail); String response = registrationHandler.getExternalDataEngineByQualifiedName(USER, QUALIFIED_NAME); assertEquals(GUID, response); verify(invalidParameterHandler, times(1)).validateUserId(USER, methodName); verify(invalidParameterHandler, times(1)).validateName(QUALIFIED_NAME, DataEnginePropertiesMapper.QUALIFIED_NAME_PROPERTY_NAME, methodName); }
@Test void getExternalDataEngineByQualifiedName_throwsUserNotAuthorizedException() throws UserNotAuthorizedException, PropertyServerException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { String methodName = "getExternalDataEngineByQualifiedName"; UserNotAuthorizedException mockedException = mockException(UserNotAuthorizedException.class, methodName); when(repositoryHandler.getUniqueEntityByName(USER, QUALIFIED_NAME, DataEnginePropertiesMapper.QUALIFIED_NAME_PROPERTY_NAME, null, DataEnginePropertiesMapper.SOFTWARE_SERVER_CAPABILITY_TYPE_GUID, DataEnginePropertiesMapper.SOFTWARE_SERVER_CAPABILITY_TYPE_NAME, methodName)).thenThrow(mockedException); UserNotAuthorizedException thrown = assertThrows(UserNotAuthorizedException.class, () -> registrationHandler.getExternalDataEngineByQualifiedName(USER, QUALIFIED_NAME)); assertTrue(thrown.getMessage().contains("OMAS-DATA-ENGINE-404-001 ")); }