Skip to content

Commit

Permalink
Test for issue #399
Browse files Browse the repository at this point in the history
Signed-off-by: Katie Richter <katierichter98@gmail.com>
  • Loading branch information
Katie-Richter committed Jul 14, 2020
1 parent 7980412 commit 590db59
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
package org.eclipse.yasson.customization;

import org.junit.jupiter.api.*;

import jakarta.json.bind.Jsonb;
import jakarta.json.bind.JsonbBuilder;
import jakarta.json.bind.annotation.JsonbProperty;

import static org.junit.jupiter.api.Assertions.*;

import static org.eclipse.yasson.Jsonbs.*;

import org.eclipse.yasson.customization.model.JsonbNillableClassSecondLevel;
Expand Down Expand Up @@ -78,4 +84,25 @@ public void testNillableInConfig() {
String jsonString = nullableJsonb.toJson(new ScalarValueWrapper<String>(){});
assertEquals("{\"value\":null}", jsonString);
}

public static class PrimitiveNullBoolean {

@JsonbProperty(nillable = true)
private Boolean someBoolean;

void setSomeBoolean(boolean value) { // note that value is a primitive boolean
// leaving this empty, exception will be thrown before Yasson gets here.
}
}

/**
* Test for issue https://github.com/eclipse-ee4j/yasson/issues/399
*/
@Test
public void testNillableSomeBoolean() {
Jsonb jsonb = JsonbBuilder.create();
String input = "{\"someBoolean\": null}";
PrimitiveNullBoolean deserialized = jsonb.fromJson(input, PrimitiveNullBoolean.class);
assertNull(deserialized.someBoolean);
}
}

0 comments on commit 590db59

Please sign in to comment.