Exemplo n.º 1
0
  @Test
  public void shouldConvertToModel() {
    User model = sut.toModel(TestDataModels.currentUser(), TestDataDto.user());

    Assert.assertEquals(TestData.USER_ID, model.getId());
    assertEquals(TestData.USER_NAME, model.getUsername());
  }
  @Override
  public void populateEntity(final UserEntity entity, final User model) {
    Assert.notNull(entity, ENTITY_MUST_NOT_BE_NULL);
    Assert.notNull(model, USER_MUST_NOT_BE_NULL);

    entity.setId(model.getId());
    entity.setUsername(model.getUsername());
  }
  @Override
  public User toModel(final UserEntity entity) {
    Assert.notNull(entity, ENTITY_MUST_NOT_BE_NULL);

    User model = new User();
    model.setId(entity.getId());
    model.setUsername(entity.getUsername());
    return model;
  }