Skip to content

Commit

Permalink
Add tests for issue #81
Browse files Browse the repository at this point in the history
Signed-off-by: Gyúróczki Gergő <gergonoorbi@gmail.com>
  • Loading branch information
Degubi committed Nov 6, 2019
1 parent e69bab5 commit 1decc28
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,33 @@ public void testRenamedGetterAndSetter() {
assertEquals("hi", b1.getTest()); //this fails but passes in 1.0.4
}

@Test
public void testRenamedGetterAndSetter2() {
// Reported in issue: https://github.com/eclipse-ee4j/yasson/issues/81
final Jsonb jsonb = JsonbBuilder.create(
new JsonbConfig().withPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE));

final RenamedGetterAndSetter2 bean1 = new RenamedGetterAndSetter2();
bean1.setAPIDocumentation("REST");

final String json = jsonb.toJson(bean1);
final RenamedGetterAndSetter2 bean2 = jsonb.fromJson(json, RenamedGetterAndSetter2.class);
assertEquals(bean1.getAPIDocumentation(), bean2.getAPIDocumentation());
}

@Test
public void testRenamedGetterAndSetter3() {
// Reported in issue: https://github.com/eclipse-ee4j/yasson/issues/81
final Jsonb jsonb = JsonbBuilder.create();

final RenamedGetterAndSetter2 bean1 = new RenamedGetterAndSetter2();
bean1.setAPIDocumentation("REST");

final String json = jsonb.toJson(bean1);
final RenamedGetterAndSetter2 bean2 = jsonb.fromJson(json, RenamedGetterAndSetter2.class);
assertEquals(bean1.getAPIDocumentation(), bean2.getAPIDocumentation());
}

public static class RenamedGetterAndSetter {
private String apple;

Expand All @@ -103,6 +130,21 @@ public void setTest(String test) {
this.apple = test;
}
}

public static class RenamedGetterAndSetter2 {

private String api;

@JsonbProperty("api")
public String getAPIDocumentation() {
return api;
}

@JsonbProperty("api")
public void setAPIDocumentation(String api) {
this.api = api;
}
}

/**
* In this test getter / setter doesn't match to field "doi", because declared by javabean convention.
Expand Down

0 comments on commit 1decc28

Please sign in to comment.