Exemplo n.º 1
0
  @Test(expected = MissingFormatArgumentException.class)
  public void createAggregatorNotAdminTest() throws Exception {

    when(userManager.isAdmin()).thenReturn(false);

    Aggregator aggregator = new Aggregator();
    aggregator.setAggregatorId("*****@*****.**");
    aggregator.setAggregatorName("aggregatorName");

    toTest.createAggregator(aggregator);

    fail();
  }
Exemplo n.º 2
0
  @Test
  public void createAggregatorTest() throws Exception {

    when(userManager.isAdmin()).thenReturn(true);

    Aggregator aggregator = new Aggregator();
    aggregator.setAggregatorId("*****@*****.**");
    aggregator.setAggregatorName("aggregatorName");

    Response response = toTest.createAggregator(aggregator);

    Assert.assertEquals(201, response.getStatus());
  }
Exemplo n.º 3
0
  @Test
  public void getAggregatorsTest() throws Exception {

    List<Aggregator> aggregators = new LinkedList<>();

    Aggregator aggregator = new Aggregator();
    aggregator.setAggregatorId("*****@*****.**");
    aggregator.setAggregatorName("aggregatorName");

    aggregators.add(aggregator);

    when(userManager.isAdmin()).thenReturn(true);
    when(aggregatorManager.getAPIAggregators()).thenReturn(aggregators);

    Response response = toTest.getAggregators();

    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals(aggregators, response.getEntity());
  }
Exemplo n.º 4
0
  @Test
  public void getAggregatorsNotAdminTest() throws Exception {

    Aggregator aggregator = new Aggregator();
    aggregator.setAggregatorId("*****@*****.**");
    aggregator.setAggregatorName("aggregatorName");

    RSUser user = new RSUser();
    user.setEmail("*****@*****.**");

    when(userManager.isAdmin()).thenReturn(false);
    when(userManager.getCurrentUser()).thenReturn(user);
    when(aggregatorManager.getAggregator("*****@*****.**")).thenReturn(aggregator);

    Response response = toTest.getAggregators();

    Assert.assertEquals(200, response.getStatus());
    List listResponse = (List) response.getEntity();
    Assert.assertEquals(aggregator, listResponse.get(0));
  }