Update Person class to use property "id" like identifier.
This commit is contained in:
@@ -30,15 +30,14 @@ public class JsonbIntegrationTest {
|
||||
ResponseEntity<Person> response = template.withBasicAuth(username, password)
|
||||
.getForEntity("/person/1", Person.class);
|
||||
Person person = response.getBody();
|
||||
assertTrue(person.equals(new Person("Jhon", "jhon1@test.com", 0, LocalDate.of(2019, 9, 9), BigDecimal.valueOf(1500.0))));
|
||||
assertTrue(person.equals(new Person(2, "Jhon", "jhon1@test.com", 0, LocalDate.of(2019, 9, 9), BigDecimal.valueOf(1500.0))));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSendPostAPerson_thenGetOkStatus() {
|
||||
ResponseEntity<Boolean> response = template.withBasicAuth(username, password)
|
||||
.postForEntity("/person", "{\"birthDate\":\"07-09-2017\",\"email\":\"jhon1@test.com\",\"person-name\":\"Jhon\"}", Boolean.class);
|
||||
boolean value = response.getBody();
|
||||
assertTrue(true == value);
|
||||
.postForEntity("/person", "{\"birthDate\":\"07-09-2017\",\"email\":\"jhon1@test.com\",\"person-name\":\"Jhon\",\"id\":10}", Boolean.class);
|
||||
assertTrue(response.getBody());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,15 +22,15 @@ public class JsonbTest {
|
||||
|
||||
@Test
|
||||
public void givenPersonObject_whenSerializeWithJsonb_thenGetPersonJson() {
|
||||
Person person = new Person("Jhon", "jhon@test.com", 20, LocalDate.of(2019, 9, 7), BigDecimal.valueOf(1000));
|
||||
Person person = new Person(1, "Jhon", "jhon@test.com", 20, LocalDate.of(2019, 9, 7), BigDecimal.valueOf(1000));
|
||||
String jsonPerson = jsonb.toJson(person);
|
||||
assertTrue("{\"email\":\"jhon@test.com\",\"person-name\":\"Jhon\",\"registeredDate\":\"07-09-2019\",\"salary\":\"1000.0\"}".equals(jsonPerson));
|
||||
assertTrue("{\"email\":\"jhon@test.com\",\"id\":1,\"person-name\":\"Jhon\",\"registeredDate\":\"07-09-2019\",\"salary\":\"1000.0\"}".equals(jsonPerson));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenPersonJson_whenDeserializeWithJsonb_thenGetPersonObject() {
|
||||
Person person = new Person("Jhon", "jhon@test.com", 0, LocalDate.of(2019, 9, 7), BigDecimal.valueOf(1000.0));
|
||||
String jsonPerson = "{\"email\":\"jhon@test.com\",\"person-name\":\"Jhon\",\"registeredDate\":\"07-09-2019\",\"salary\":\"1000.0\"}";
|
||||
Person person = new Person(1, "Jhon", "jhon@test.com", 0, LocalDate.of(2019, 9, 7), BigDecimal.valueOf(1000.0));
|
||||
String jsonPerson = "{\"email\":\"jhon@test.com\",\"id\":1,\"person-name\":\"Jhon\",\"registeredDate\":\"07-09-2019\",\"salary\":\"1000.0\"}";
|
||||
assertTrue(jsonb.fromJson(jsonPerson, Person.class)
|
||||
.equals(person));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user