TenantManage { public String getObjectId(UserId userId, String name){ if (userNameIdMap.containsKey(userId)){ if (userNameIdMap.get(userId).containsKey(name)){ return userNameIdMap.get(userId).get(name); } } return null; } TenantManage(DataBroker dataBroker); User getUser(); Map<UserRoleName, UserRole> getUserRoles(); Map<UserId, User> getUsers(); void fetchVNSpace(UserId userId); void addUser(RegisterUserInput registerUserInput); void transactionHandling(UserId userId); void setNode(UserId userId, NodeId nodeId, Node node); Map<NodeId, Node> getNode(UserId userId); void setConnection(UserId userId, ConnectionId connectionId, Connection connection); Map<ConnectionId, Connection> getConnection(UserId userId); void setFlow(UserId userId, FlowId flowId, Flow flow); Map<FlowId,Flow> getFlow(UserId userId); void setOperation(UserId userId, OperationId operationId, Operation operation); Map<OperationId, Operation> getOperation(UserId userId); void setTemplateDefinition(UserId userId,TemplateName templateName, TemplateDefinition definition); Map<TemplateName, TemplateDefinition> getTempalteDefinition(UserId userId); void setUserTemplateInstance(UserId userId, TemplateInstanceId instanceId, TemplateInstance instance); Map<TemplateInstanceId, TemplateInstance> getTemplateInstance(UserId userId); void setUserDeleteIntent(UserId userId, String type, String objectId); void setUserNameIdMap(UserId userId, String name, String objectId); Map<String, String> getUserNameIdMap(UserId userId); String getObjectId(UserId userId, String name); String getName(UserId userId, String objectId); Map<NodeId, Node> getNodeDataStore(UserId userId); Map<ConnectionId, Connection> getConnectionDataStore(UserId userId); Map<FlowId, Flow> getFlowDataStore(UserId userId); Map<OperationId, Operation> getOperationDataStore(UserId userId); Map<TemplateName, TemplateDefinition> getDefinitionDataStore(UserId userId); Map<TemplateInstanceId, TemplateInstance> getInstanceDataStore(UserId userId);  }
@Test public void testGetObjectId() throws Exception { UserId userId = mock(UserId.class); String name = "name"; Map<UserId, Map<String, String>> userNameIdMap = mock(Map.class); Map<String, String> temp = mock(Map.class); Assert.assertTrue(tenantManage.getObjectId(userId,name) == null); field_userNameIdMap.set(tenantManage, userNameIdMap); when(userNameIdMap.containsKey(userId)).thenReturn(true); when(userNameIdMap.get(userId)).thenReturn(temp); when(userNameIdMap.get(userId).containsKey(name)).thenReturn(true); when(userNameIdMap.get(userId).get(name)).thenReturn("test"); Assert.assertTrue(tenantManage.getObjectId(userId,name).equals("test")); }