Exemplo n.º 1
0
  @Test
  public void saveProxy_modify() {
    when(aclServiceDao.getProxy(IpInterval.parse("10.0.0.0/32")))
        .thenReturn(new Proxy("10.0.0.0/32", ""));

    final Proxy proxy = new Proxy("10.0.0.0/32", "some");
    final Response response = subject.saveProxy(proxy);
    assertThat(response.getStatus(), is(Response.Status.OK.getStatusCode()));
    assertThat(response.getEntity(), instanceOf(Proxy.class));
    assertThat(((Proxy) response.getEntity()).getPrefix(), is("10.0.0.0/32"));

    verify(aclServiceDao).updateProxy(proxy);
  }
Exemplo n.º 2
0
  @Test
  public void saveProxy_create() {
    when(aclServiceDao.getProxy(IpInterval.parse("10.0.0.0/32")))
        .thenThrow(EmptyResultDataAccessException.class);

    final Proxy proxy = new Proxy("10.0.0.0/32", "some");
    final Response response = subject.saveProxy(proxy);
    assertThat(response.getStatus(), is(Response.Status.OK.getStatusCode()));
    assertThat(response.getEntity(), instanceOf(Proxy.class));
    assertThat(((Proxy) response.getEntity()).getPrefix(), is("10.0.0.0/32"));

    verify(aclServiceDao).createProxy(proxy);
  }