public void testDeleteMailingList() {
   MailingList mailingList = new MailingList();
   mailingList.setComponentId("componentId");
   ExternalUser user = new ExternalUser();
   user.setEmail("*****@*****.**");
   user.setComponentId("componentId");
   mailingList.getExternalSubscribers().add(user);
   user = new ExternalUser();
   user.setEmail("*****@*****.**");
   user.setComponentId("componentId");
   mailingList.getExternalSubscribers().add(user);
   String id = mailingListDao.createMailingList(mailingList);
   assertNotNull(id);
   mailingList = mailingListDao.findById(id);
   assertNotNull(mailingList);
   assertEquals("componentId", mailingList.getComponentId());
   assertEquals(1, countRowsInTable("SC_MAILINGLIST_LIST"));
   assertEquals(2, countRowsInTable("SC_MAILINGLIST_EXTERNAL_USER"));
   assertNotNull(mailingList.getExternalSubscribers());
   assertEquals(2, mailingList.getExternalSubscribers().size());
   mailingListDao.deleteMailingList(mailingList);
   mailingList = mailingListDao.findById(id);
   assertNull(mailingList);
   assertEquals(0, countRowsInTable("SC_MAILINGLIST_LIST"));
   assertEquals(0, countRowsInTable("SC_MAILINGLIST_EXTERNAL_USER"));
 }
 public void testListMailingList() {
   MailingList mailingList = new MailingList();
   mailingList.setComponentId("componentId1");
   ExternalUser user = new ExternalUser();
   user.setEmail("*****@*****.**");
   user.setComponentId("componentId1");
   mailingList.getExternalSubscribers().add(user);
   String id1 = mailingListDao.createMailingList(mailingList);
   assertNotNull(id1);
   mailingList = new MailingList();
   mailingList.setComponentId("componentId2");
   user = new ExternalUser();
   user.setEmail("*****@*****.**");
   user.setComponentId("componentId2");
   mailingList.getExternalSubscribers().add(user);
   String id2 = mailingListDao.createMailingList(mailingList);
   assertNotNull(id2);
   List mailingLists = this.mailingListDao.listMailingLists();
   assertEquals(2, countRowsInTable("SC_MAILINGLIST_LIST"));
   assertEquals(2, countRowsInTable("SC_MAILINGLIST_EXTERNAL_USER"));
   assertNotNull(mailingLists);
   assertEquals(2, mailingLists.size());
 }
 public void testCreateMailingList() {
   MailingList mailingList = new MailingList();
   mailingList.setComponentId("componentId");
   ExternalUser user = new ExternalUser();
   user.setEmail("*****@*****.**");
   user.setComponentId("componentId");
   mailingList.getExternalSubscribers().add(user);
   String id = mailingListDao.createMailingList(mailingList);
   assertNotNull(id);
   MailingList saved = mailingListDao.findById(id);
   assertNotNull(saved);
   assertEquals("componentId", saved.getComponentId());
   assertEquals(1, countRowsInTable("SC_MAILINGLIST_LIST"));
   assertEquals(1, countRowsInTable("SC_MAILINGLIST_EXTERNAL_USER"));
   assertNotNull(saved.getExternalSubscribers());
   assertEquals(1, saved.getExternalSubscribers().size());
   ExternalUser savedUser = (ExternalUser) saved.getExternalSubscribers().iterator().next();
   assertNotNull(savedUser.getId());
   assertNotNull("componentId", savedUser.getComponentId());
 }