@Test public void testGetUsersInGroups() { List<String> users = Arrays.asList("user1","user2","user3"); createUsers(users,"group1"); List<String> users2 = Arrays.asList("user12","user22"); createUsers(users2,"group2"); Collection<String> allUsers = serviceImpl.getUsersInGroup("group1"); Assert.assertEquals(allUsers.size(), users.size()); Assert.assertTrue(allUsers.containsAll(users)); allUsers = serviceImpl.getUsersInGroup("group2"); Assert.assertEquals(allUsers.size(), users2.size()); Assert.assertTrue(allUsers.containsAll(users2)); }
@Override public Collection<String> getUsersInGroup(String group) { EntityManager em = entityManagerFactory.createEntityManager(); List<String> userNames = null; try { TypedQuery<MctUsers> q = em.createNamedQuery("MctUsers.findByGroup", MctUsers.class); q.setParameter("group", group); List<MctUsers> users = q.getResultList(); userNames = new ArrayList<String>(users.size()); for (MctUsers u:users) { userNames.add(u.getUserId()); } } finally { em.close(); } return userNames; }
PersistenceServiceImpl implements PersistenceProvider { @Override public Collection<String> getUsersInGroup(String group) { EntityManager em = entityManagerFactory.createEntityManager(); List<String> userNames = null; try { TypedQuery<MctUsers> q = em.createNamedQuery("MctUsers.findByGroup", MctUsers.class); q.setParameter("group", group); List<MctUsers> users = q.getResultList(); userNames = new ArrayList<String>(users.size()); for (MctUsers u:users) { userNames.add(u.getUserId()); } } finally { em.close(); } return userNames; } }
PersistenceServiceImpl implements PersistenceProvider { @Override public Collection<String> getUsersInGroup(String group) { EntityManager em = entityManagerFactory.createEntityManager(); List<String> userNames = null; try { TypedQuery<MctUsers> q = em.createNamedQuery("MctUsers.findByGroup", MctUsers.class); q.setParameter("group", group); List<MctUsers> users = q.getResultList(); userNames = new ArrayList<String>(users.size()); for (MctUsers u:users) { userNames.add(u.getUserId()); } } finally { em.close(); } return userNames; }  }
PersistenceServiceImpl implements PersistenceProvider { @Override public Collection<String> getUsersInGroup(String group) { EntityManager em = entityManagerFactory.createEntityManager(); List<String> userNames = null; try { TypedQuery<MctUsers> q = em.createNamedQuery("MctUsers.findByGroup", MctUsers.class); q.setParameter("group", group); List<MctUsers> users = q.getResultList(); userNames = new ArrayList<String>(users.size()); for (MctUsers u:users) { userNames.add(u.getUserId()); } } finally { em.close(); } return userNames; }  void bind(Platform platform); void unbind(Platform platform); void setEntityManagerProperties(Properties p); void activate(ComponentContext context); @Override AbstractComponent getComponentFromStore(String componentId); @Override AbstractComponent getComponent(String componentId); @Override Collection<AbstractComponent> getReferences(AbstractComponent component); @Override void startRelatedOperations(); @Override void completeRelatedOperations(boolean save); @Override void addComponentToWorkUnit(AbstractComponent component); Collection<AbstractComponent> getCurrentComponents(); @Override Set<String> getAllUsers(); @Override Collection<String> getUsersInGroup(String group); @Override void persist(Collection<AbstractComponent> componentsToPersist); @Override void delete(Collection<AbstractComponent> componentsToDelete); @Override boolean hasComponentsTaggedBy(String tagId); @Override List<AbstractComponent> getReferencedComponents(
			AbstractComponent component); @Override User getUser(String userId); @SuppressWarnings("unchecked") QueryResult findComponentsByBaseDisplayedNamePattern(String pattern, Properties props); @Override T getComponent(String externalKey, Class<T> componentType); @Override void updateComponentsFromDatabase(); @Override List<AbstractComponent> getBootstrapComponents(); @Override void addNewUser(String userId, String groupId, AbstractComponent mysandbox, AbstractComponent dropbox); @Override Map<String, ExtendedProperties> getAllProperties(String componentId); @Override AbstractComponent getComponent(String externalKey,
			String componentType); @Override void tagComponents(String tag,
			Collection<AbstractComponent> components); }
PersistenceServiceImpl implements PersistenceProvider { @Override public Collection<String> getUsersInGroup(String group) { EntityManager em = entityManagerFactory.createEntityManager(); List<String> userNames = null; try { TypedQuery<MctUsers> q = em.createNamedQuery("MctUsers.findByGroup", MctUsers.class); q.setParameter("group", group); List<MctUsers> users = q.getResultList(); userNames = new ArrayList<String>(users.size()); for (MctUsers u:users) { userNames.add(u.getUserId()); } } finally { em.close(); } return userNames; }  void bind(Platform platform); void unbind(Platform platform); void setEntityManagerProperties(Properties p); void activate(ComponentContext context); @Override AbstractComponent getComponentFromStore(String componentId); @Override AbstractComponent getComponent(String componentId); @Override Collection<AbstractComponent> getReferences(AbstractComponent component); @Override void startRelatedOperations(); @Override void completeRelatedOperations(boolean save); @Override void addComponentToWorkUnit(AbstractComponent component); Collection<AbstractComponent> getCurrentComponents(); @Override Set<String> getAllUsers(); @Override Collection<String> getUsersInGroup(String group); @Override void persist(Collection<AbstractComponent> componentsToPersist); @Override void delete(Collection<AbstractComponent> componentsToDelete); @Override boolean hasComponentsTaggedBy(String tagId); @Override List<AbstractComponent> getReferencedComponents(
			AbstractComponent component); @Override User getUser(String userId); @SuppressWarnings("unchecked") QueryResult findComponentsByBaseDisplayedNamePattern(String pattern, Properties props); @Override T getComponent(String externalKey, Class<T> componentType); @Override void updateComponentsFromDatabase(); @Override List<AbstractComponent> getBootstrapComponents(); @Override void addNewUser(String userId, String groupId, AbstractComponent mysandbox, AbstractComponent dropbox); @Override Map<String, ExtendedProperties> getAllProperties(String componentId); @Override AbstractComponent getComponent(String externalKey,
			String componentType); @Override void tagComponents(String tag,
			Collection<AbstractComponent> components);  }