### Question:
AuthResourceInMemoryDao implements AuthResourceDao { @Override public void persist(AuthResource authResource) throws AuthServerException { String resourceType = authResource.getResourceType(); String resourceName = authResource.getResourceName(); if (!inMemoryResourceMap.contains(resourceType, resourceName)) { inMemoryResourceMap.put(resourceType, resourceName, authResource); } else { throw new AuthServerException( "Auth resource already exists [" + resourceType + ", " + resourceName + "]"); } }  @Override void persist(AuthResource authResource); @Override void update(AuthResource authResource); @Override boolean delete(String resourceType, String resource); @Override AuthResource read(String resourceType, String resource); @Override List<AuthResource> readAll(String resourceType, String ownerId); @Override List<AuthResource> readAll(String resourceType, String action, String ownerId, List<String> userGroups); @Override boolean isExists(String resourceType, String resourceName); @Override boolean updateOwner(String resourceType, String resourceName, String newOwner); @Override boolean addGroups(String resourceType, String resourceName, String action, List<String> groups); @Override boolean removeGroup(String resourceType, String resourceName, String action, String group);  }### Answer:
@Test public void testPersist() throws AuthServerException { AuthResource queue = new AuthResource(ResourceType.QUEUE.toString(), "queue1", true, "customer"); authResourceDao.persist(queue); Map<String, Set<String>> actionsUserGroupsMap = new HashMap<>(); actionsUserGroupsMap.put("bind", new HashSet<>(Arrays.asList("architect", "developer"))); AuthResource exchange = new AuthResource(ResourceType.EXCHANGE.toString(), "exchange1", true, "manager", actionsUserGroupsMap); actionsUserGroupsMap = new HashMap<>(); actionsUserGroupsMap.put("bind", new HashSet<>(Collections.singletonList("architect"))); AuthResource exchange2 = new AuthResource(ResourceType.EXCHANGE.toString(), "exchange2", true, "manager", actionsUserGroupsMap); authResourceDao.persist(exchange); authResourceDao.persist(exchange2); }
@Test(priority = 1, expectedExceptions = AuthServerException.class) public void testDuplicate() throws AuthServerException { AuthResource queue = new AuthResource(ResourceType.QUEUE.toString(), "queue1", true, "customer"); authResourceDao.persist(queue); }