コード例 #1
0
  @Test
  public void testGetMappedLinks() {
    MailingListMapping m1 =
        new MailingListMapping("1", "purpose1", "^(hello) (world)$", "{1}_1_{2}", "Mapping 1");
    MailingListMapping m2 =
        new MailingListMapping("2", "purpose1", "^(hello) (world)$", "{1}_2_{2}", "Mapping 2");
    MailingListMapping m3 =
        new MailingListMapping("3", "purpose1", "^(hello)no(world)$", "{1}_1_{2}", "Mapping 3");
    ArrayList<MailingListMapping> ms = new ArrayList<MailingListMapping>(3);
    ms.add(m1);
    ms.add(m2);
    ms.add(m3);
    MailingListMappings mappings = new MailingListMappings(ms);

    final ConfigurationService mockConfigService = EasyMock.createMock(ConfigurationService.class);
    Object[] mocks = new Object[] {mockConfigService};

    EasyMock.reset(mocks);

    mockConfigService.readConfiguration(MailingListMappings.class);
    EasyMock.expectLastCall().andReturn(mappings);

    EasyMock.replay(mocks);

    MailingListMapper mapper = new MailingListMapper(LinkMapper.ALL_PURPOSES);
    Project project = new Project("some.project", "Some Project", "Some Project");
    List<Link> res = mapper.getMappedLinks("hello world", "homer", project, mockConfigService);
    EasyMock.verify(mocks);

    Assert.assertNotNull(res);
    Assert.assertEquals(2, res.size());
  }
コード例 #2
0
  @Test
  public void testGetMappedLinks_noConfig() {
    final ConfigurationService mockConfigService = EasyMock.createMock(ConfigurationService.class);
    Object[] mocks = new Object[] {mockConfigService};

    EasyMock.reset(mocks);

    mockConfigService.readConfiguration(MailingListMappings.class);
    EasyMock.expectLastCall().andReturn(null);

    EasyMock.replay(mocks);

    MailingListMapper mapper = new MailingListMapper(LinkMapper.ALL_PURPOSES);
    Project project = new Project("some.project", "Some Project", "Some Project");
    List<Link> res = mapper.getMappedLinks("hello world", "homer", project, mockConfigService);
    EasyMock.verify(mocks);

    Assert.assertNotNull(res);
    Assert.assertEquals(0, res.size());
  }