Exemplo n.º 1
0
  @Test
  public void testFindByIdWithClientServiceShouldPass() throws Exception {

    client.setName("test findById");
    clientService.create(client);
    Integer insertedId = client.getId();

    Client result = clientService.findById(insertedId);

    assertThat(result.getName(), is("test findById"));
  }
Exemplo n.º 2
0
  @Test
  public void testFindAllWithClientServiceShouldPass() throws Exception {

    List<Client> clients = clientService.findAll();

    clientService.create(client);

    List<Client> result = clientService.findAll();

    assertThat(result.size(), is(clients.size() + 1));
  }
Exemplo n.º 3
0
  @Test
  public void testDeleteWithClientServiceShouldPass() throws Exception {

    clientService.create(client);
    Integer insertedId = client.getId();

    Client delete = clientService.findById(insertedId);
    clientService.delete(delete);

    Client result = clientService.findById(delete.getId());

    assertNull(result);
  }
Exemplo n.º 4
0
  public String save() {
    if (client.getUser() == null) {
      client.setUser(getSessionUser());
    }
    if (service.find(client.getClientId()) != null) {
      service.update(client);

    } else {
      service.create(client);
    }
    FacesContext.getCurrentInstance()
        .addMessage(
            null, new FacesMessage(FacesMessage.SEVERITY_INFO, "client saved successfully!", null));
    return "list";
  }
  private Client createClient() {
    UserAdmin user = new UserAdmin(1l, 0);

    Client client = new Client();
    client.setTier(new ClientTier(3l));
    client.setContractEnd(LocalDate.now().plusYears(1));
    client.setContractStart(LocalDate.now());
    client.setRegion(new ClientRegion(1l));
    client.setName("Test Client " + RandomStringUtils.randomAlphanumeric(18));
    client.setType(new ClientType(1l));
    client.setContractOwner(user);
    client.setActive(false);
    client.setSalesForceAccount(new SalesForce(RandomStringUtils.randomAlphanumeric(18)));
    clientService.create(client);
    return client;
  }