-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:(jans-auth-server): fixed Client serialization/deserialization is…
…sue #2946 (#3064) * fix:(jans-auth-server): fixed Client serialization/deserialization bug #2946 * fix:(jans-auth-server): fixed Client serialization/deserialization bug #2946
- Loading branch information
Showing
3 changed files
with
93 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...er/common/src/test/java/io/jans/as/common/model/registration/ClientSerializationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io.jans.as.common.model.registration; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import io.jans.as.model.util.Util; | ||
import org.testng.annotations.Test; | ||
|
||
import java.io.IOException; | ||
import java.util.Locale; | ||
|
||
import static org.testng.AssertJUnit.assertEquals; | ||
import static org.testng.AssertJUnit.assertNotNull; | ||
|
||
/** | ||
* @author Yuriy Zabrovarnyy | ||
*/ | ||
public class ClientSerializationTest { | ||
|
||
@Test | ||
public void deserialization_whenSerialized_shouldGetCorrectValues() throws IOException { | ||
Client c = new Client(); | ||
c.setClientName("name"); | ||
c.setClientNameLocalized("myLocalized"); | ||
c.setClientNameLocalized("myLocalized_canada", Locale.CANADA); | ||
c.setClientNameLocalized("myLocalized_canadaFR", Locale.CANADA_FRENCH); | ||
|
||
final ObjectMapper mapper = Util.createJsonMapper(); | ||
mapper.setDefaultPropertyInclusion(JsonInclude.Include.NON_EMPTY); | ||
final String asJson = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(c); | ||
|
||
final Client client = mapper.readValue(asJson, Client.class); | ||
assertNotNull(client); | ||
assertEquals("myLocalized", client.getClientName()); | ||
assertEquals("myLocalized", client.getClientNameLocalized().getValue()); | ||
assertEquals("myLocalized_canada", client.getClientNameLocalized().getValue(Locale.CANADA)); | ||
assertEquals("myLocalized_canadaFR", client.getClientNameLocalized().getValue(Locale.CANADA_FRENCH)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters