@Test void findEntity_throwsUserNotAuthorizedException() throws PropertyServerException, UserNotAuthorizedException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { String methodName = "findEntity"; when(repositoryHelper.getExactMatchRegex(QUALIFIED_NAME)).thenReturn(QUALIFIED_NAME); UserNotAuthorizedException mockedException = mockException(UserNotAuthorizedException.class, methodName); when(repositoryHandler.getUniqueEntityByName(USER, QUALIFIED_NAME, CommonMapper.QUALIFIED_NAME_PROPERTY_NAME, null, ENTITY_TYPE_GUID, ENTITY_TYPE_NAME, methodName)).thenThrow(mockedException); UserNotAuthorizedException thrown = assertThrows(UserNotAuthorizedException.class, () -> dataEngineCommonHandler.findEntity(USER, QUALIFIED_NAME, ENTITY_TYPE_NAME)); assertTrue(thrown.getMessage().contains("OMAS-DATA-ENGINE-404-001 ")); }
protected Optional<EntityDetail> findEntity(String userId, String qualifiedName, String entityTypeName) throws UserNotAuthorizedException, PropertyServerException, InvalidParameterException { final String methodName = "findEntity"; invalidParameterHandler.validateUserId(userId, methodName); invalidParameterHandler.validateName(qualifiedName, CommonMapper.QUALIFIED_NAME_PROPERTY_NAME, methodName); qualifiedName = repositoryHelper.getExactMatchRegex(qualifiedName); InstanceProperties properties = repositoryHelper.addStringPropertyToInstance(serviceName, null, CommonMapper.QUALIFIED_NAME_PROPERTY_NAME, qualifiedName, methodName); TypeDef entityTypeDef = repositoryHelper.getTypeDefByName(userId, entityTypeName); Optional<EntityDetail> retrievedEntity = Optional.ofNullable(repositoryHandler.getUniqueEntityByName(userId, qualifiedName, CommonMapper.QUALIFIED_NAME_PROPERTY_NAME, properties, entityTypeDef.getGUID(), entityTypeDef.getName(), methodName)); log.debug("Searching for entity with qualifiedName: {}. Result is {}", qualifiedName, retrievedEntity.map(InstanceHeader::getGUID).orElse(null)); return retrievedEntity; }
DataEngineCommonHandler { protected Optional<EntityDetail> findEntity(String userId, String qualifiedName, String entityTypeName) throws UserNotAuthorizedException, PropertyServerException, InvalidParameterException { final String methodName = "findEntity"; invalidParameterHandler.validateUserId(userId, methodName); invalidParameterHandler.validateName(qualifiedName, CommonMapper.QUALIFIED_NAME_PROPERTY_NAME, methodName); qualifiedName = repositoryHelper.getExactMatchRegex(qualifiedName); InstanceProperties properties = repositoryHelper.addStringPropertyToInstance(serviceName, null, CommonMapper.QUALIFIED_NAME_PROPERTY_NAME, qualifiedName, methodName); TypeDef entityTypeDef = repositoryHelper.getTypeDefByName(userId, entityTypeName); Optional<EntityDetail> retrievedEntity = Optional.ofNullable(repositoryHandler.getUniqueEntityByName(userId, qualifiedName, CommonMapper.QUALIFIED_NAME_PROPERTY_NAME, properties, entityTypeDef.getGUID(), entityTypeDef.getName(), methodName)); log.debug("Searching for entity with qualifiedName: {}. Result is {}", qualifiedName, retrievedEntity.map(InstanceHeader::getGUID).orElse(null)); return retrievedEntity; } }
DataEngineCommonHandler { protected Optional<EntityDetail> findEntity(String userId, String qualifiedName, String entityTypeName) throws UserNotAuthorizedException, PropertyServerException, InvalidParameterException { final String methodName = "findEntity"; invalidParameterHandler.validateUserId(userId, methodName); invalidParameterHandler.validateName(qualifiedName, CommonMapper.QUALIFIED_NAME_PROPERTY_NAME, methodName); qualifiedName = repositoryHelper.getExactMatchRegex(qualifiedName); InstanceProperties properties = repositoryHelper.addStringPropertyToInstance(serviceName, null, CommonMapper.QUALIFIED_NAME_PROPERTY_NAME, qualifiedName, methodName); TypeDef entityTypeDef = repositoryHelper.getTypeDefByName(userId, entityTypeName); Optional<EntityDetail> retrievedEntity = Optional.ofNullable(repositoryHandler.getUniqueEntityByName(userId, qualifiedName, CommonMapper.QUALIFIED_NAME_PROPERTY_NAME, properties, entityTypeDef.getGUID(), entityTypeDef.getName(), methodName)); log.debug("Searching for entity with qualifiedName: {}. Result is {}", qualifiedName, retrievedEntity.map(InstanceHeader::getGUID).orElse(null)); return retrievedEntity; } DataEngineCommonHandler(String serviceName, String serverName, InvalidParameterHandler invalidParameterHandler,
                                   RepositoryHandler repositoryHandler, OMRSRepositoryHelper repositoryHelper,
                                   DataEngineRegistrationHandler dataEngineRegistrationHandler); }
DataEngineCommonHandler { protected Optional<EntityDetail> findEntity(String userId, String qualifiedName, String entityTypeName) throws UserNotAuthorizedException, PropertyServerException, InvalidParameterException { final String methodName = "findEntity"; invalidParameterHandler.validateUserId(userId, methodName); invalidParameterHandler.validateName(qualifiedName, CommonMapper.QUALIFIED_NAME_PROPERTY_NAME, methodName); qualifiedName = repositoryHelper.getExactMatchRegex(qualifiedName); InstanceProperties properties = repositoryHelper.addStringPropertyToInstance(serviceName, null, CommonMapper.QUALIFIED_NAME_PROPERTY_NAME, qualifiedName, methodName); TypeDef entityTypeDef = repositoryHelper.getTypeDefByName(userId, entityTypeName); Optional<EntityDetail> retrievedEntity = Optional.ofNullable(repositoryHandler.getUniqueEntityByName(userId, qualifiedName, CommonMapper.QUALIFIED_NAME_PROPERTY_NAME, properties, entityTypeDef.getGUID(), entityTypeDef.getName(), methodName)); log.debug("Searching for entity with qualifiedName: {}. Result is {}", qualifiedName, retrievedEntity.map(InstanceHeader::getGUID).orElse(null)); return retrievedEntity; } DataEngineCommonHandler(String serviceName, String serverName, InvalidParameterHandler invalidParameterHandler,
                                   RepositoryHandler repositoryHandler, OMRSRepositoryHelper repositoryHelper,
                                   DataEngineRegistrationHandler dataEngineRegistrationHandler);  }
DataEngineCommonHandler { protected Optional<EntityDetail> findEntity(String userId, String qualifiedName, String entityTypeName) throws UserNotAuthorizedException, PropertyServerException, InvalidParameterException { final String methodName = "findEntity"; invalidParameterHandler.validateUserId(userId, methodName); invalidParameterHandler.validateName(qualifiedName, CommonMapper.QUALIFIED_NAME_PROPERTY_NAME, methodName); qualifiedName = repositoryHelper.getExactMatchRegex(qualifiedName); InstanceProperties properties = repositoryHelper.addStringPropertyToInstance(serviceName, null, CommonMapper.QUALIFIED_NAME_PROPERTY_NAME, qualifiedName, methodName); TypeDef entityTypeDef = repositoryHelper.getTypeDefByName(userId, entityTypeName); Optional<EntityDetail> retrievedEntity = Optional.ofNullable(repositoryHandler.getUniqueEntityByName(userId, qualifiedName, CommonMapper.QUALIFIED_NAME_PROPERTY_NAME, properties, entityTypeDef.getGUID(), entityTypeDef.getName(), methodName)); log.debug("Searching for entity with qualifiedName: {}. Result is {}", qualifiedName, retrievedEntity.map(InstanceHeader::getGUID).orElse(null)); return retrievedEntity; } DataEngineCommonHandler(String serviceName, String serverName, InvalidParameterHandler invalidParameterHandler,
                                   RepositoryHandler repositoryHandler, OMRSRepositoryHelper repositoryHelper,
                                   DataEngineRegistrationHandler dataEngineRegistrationHandler);   }