### Question:
PortHandler { public void addPortSchemaRelationship(String userId, String portGUID, String schemaTypeGUID, String externalSourceName) throws InvalidParameterException, UserNotAuthorizedException, PropertyServerException { dataEngineCommonHandler.createOrUpdateExternalRelationship(userId, portGUID, schemaTypeGUID, PortPropertiesMapper.PORT_SCHEMA_TYPE_NAME, PortPropertiesMapper.PORT_TYPE_NAME, externalSourceName, null); } PortHandler(String serviceName, String serverName, InvalidParameterHandler invalidParameterHandler, RepositoryHandler repositoryHandler,
                       OMRSRepositoryHelper repositoryHelper, DataEngineCommonHandler dataEngineCommonHandler); String createPortImplementation(String userId, PortImplementation portImplementation, String externalSourceName); String createPortAlias(String userId, PortAlias portAlias, String externalSourceName); void updatePortImplementation(String userId, EntityDetail originalPortEntity, PortImplementation portImplementation); void updatePortAlias(String userId, EntityDetail originalPortEntity, PortAlias portAlias); void addPortSchemaRelationship(String userId, String portGUID, String schemaTypeGUID, String externalSourceName); String findSchemaTypeForPort(String userId, String portGUID); void addPortDelegationRelationship(String userId, String portGUID, PortType portType, String delegatesToQualifiedName,
                                              String externalSourceName); void removePort(String userId, String portGUID, String entityTypeName); Optional<EntityDetail> findPortImplementationEntity(String userId, String qualifiedName); Optional<EntityDetail> findPortAliasEntity(String userId, String qualifiedName); Optional<EntityDetail> findPortEntity(String userId, String qualifiedName);  }### Answer:
@Test void addPortSchemaRelationship() throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { portHandler.addPortSchemaRelationship(USER, GUID, SCHEMA_GUID, EXTERNAL_SOURCE_DE_QUALIFIED_NAME); verify(dataEngineCommonHandler, times(1)).createOrUpdateExternalRelationship(USER, GUID, SCHEMA_GUID, PortPropertiesMapper.PORT_SCHEMA_TYPE_NAME, PortPropertiesMapper.PORT_TYPE_NAME, EXTERNAL_SOURCE_DE_QUALIFIED_NAME, null); }
@Test void addPortSchemaRelationship_throwsUserNotAuthorizedException() throws PropertyServerException, UserNotAuthorizedException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvalidParameterException { String methodName = "addPortSchemaRelationship"; UserNotAuthorizedException mockedException = mockException(UserNotAuthorizedException.class, methodName); doThrow(mockedException).when(dataEngineCommonHandler).createOrUpdateExternalRelationship(USER, GUID, SCHEMA_GUID, PortPropertiesMapper.PORT_SCHEMA_TYPE_NAME, PortPropertiesMapper.PORT_TYPE_NAME, EXTERNAL_SOURCE_DE_QUALIFIED_NAME, null); UserNotAuthorizedException thrown = assertThrows(UserNotAuthorizedException.class, () -> portHandler.addPortSchemaRelationship(USER, GUID, SCHEMA_GUID, EXTERNAL_SOURCE_DE_QUALIFIED_NAME)); assertTrue(thrown.getMessage().contains("OMAS-DATA-ENGINE-404-001 ")); }