|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * Copyright (c) 2019, 2020 Payara Foundation and/or its affiliates. All rights reserved.
|
4 | 4 | *
|
5 | 5 | * This program and the accompanying materials are made available under the
|
|
13 | 13 |
|
14 | 14 | package org.eclipse.yasson.defaultmapping.specific;
|
15 | 15 |
|
| 16 | +import org.eclipse.yasson.defaultmapping.specific.model.SpecificOptionalWrapper; |
16 | 17 | import org.junit.jupiter.api.*;
|
| 18 | + |
| 19 | +import static org.hamcrest.CoreMatchers.is; |
| 20 | +import static org.hamcrest.MatcherAssert.assertThat; |
17 | 21 | import static org.junit.jupiter.api.Assertions.*;
|
18 | 22 | import static org.eclipse.yasson.Jsonbs.*;
|
19 | 23 |
|
@@ -189,6 +193,20 @@ public void testUnmarshalEmptyDouble() {
|
189 | 193 | assertEquals(OptionalDouble.empty(), bindingJsonb.fromJson("null", OptionalDouble.class));
|
190 | 194 | }
|
191 | 195 |
|
| 196 | + @Test |
| 197 | + public void testNullInsteadOfOptional() { |
| 198 | + OptionalWrapper optionalWrapper = new OptionalWrapper(); |
| 199 | + String expected = "{}"; |
| 200 | + assertThat(bindingJsonb.toJson(optionalWrapper), is(expected)); |
| 201 | + } |
| 202 | + |
| 203 | + @Test |
| 204 | + public void testNullInsteadOfOptionalInSpecificOptionals() { |
| 205 | + SpecificOptionalWrapper optionalWrapper = new SpecificOptionalWrapper(); |
| 206 | + String expected = "{}"; |
| 207 | + assertThat(bindingJsonb.toJson(optionalWrapper), is(expected)); |
| 208 | + } |
| 209 | + |
192 | 210 | public static class Customer {
|
193 | 211 | private int id;
|
194 | 212 | private String name;
|
|
0 commit comments