|
39 | 39 | import org.junit.BeforeClass;
|
40 | 40 | import org.junit.Test;
|
41 | 41 |
|
| 42 | +import com.ibm.ws.repository.common.enums.DisplayPolicy; |
42 | 43 | import com.ibm.ws.repository.common.enums.Visibility;
|
43 | 44 | import com.ibm.ws.repository.transport.client.DataModelSerializer;
|
44 | 45 | import com.ibm.ws.repository.transport.client.JSONIgnore;
|
45 | 46 | import com.ibm.ws.repository.transport.exceptions.BadVersionException;
|
46 | 47 | import com.ibm.ws.repository.transport.model.Asset;
|
| 48 | +import com.ibm.ws.repository.transport.model.Provider; |
47 | 49 | import com.ibm.ws.repository.transport.model.WlpInformation;
|
48 | 50 |
|
49 | 51 | public class DataModelSerializerTest {
|
@@ -422,7 +424,7 @@ public void setStringList(List<String> stringList) {
|
422 | 424 | }
|
423 | 425 |
|
424 | 426 | @Test
|
425 |
| - public void deserializePrimitives() throws Exception { |
| 427 | + public void testDeserializePrimitives() throws Exception { |
426 | 428 |
|
427 | 429 | DeserialisationHelperClass dhc = DataModelSerializer.deserializeObject(new ByteArrayInputStream("{ \"intField\": 25 }".getBytes()),
|
428 | 430 | DeserialisationHelperClass.class);
|
@@ -511,6 +513,59 @@ public void testDeserializeBooleans() throws Exception {
|
511 | 513 | }
|
512 | 514 | }
|
513 | 515 |
|
| 516 | + public static class JsonOrderingHelperClass { |
| 517 | + String stringAlpha; |
| 518 | + String stringGamma; |
| 519 | + String stringBeta; |
| 520 | + |
| 521 | + List<String> stringList; |
| 522 | + |
| 523 | + public String getStringAlpha() { |
| 524 | + return "alphaValue"; |
| 525 | + } |
| 526 | + |
| 527 | + public String getStringGamma() { |
| 528 | + return "gammaValue"; |
| 529 | + } |
| 530 | + |
| 531 | + public String getStringBeta() { |
| 532 | + return "betaValue"; |
| 533 | + } |
| 534 | + } |
| 535 | + |
| 536 | + @Test |
| 537 | + public void testJsonOrdering() throws Exception { |
| 538 | + String actual; |
| 539 | + JsonOrderingHelperClass johc = new JsonOrderingHelperClass(); |
| 540 | + actual = DataModelSerializer.serializeAsString(johc); |
| 541 | + String expected = "{\"stringAlpha\":\"alphaValue\",\"stringBeta\":\"betaValue\",\"stringGamma\":\"gammaValue\"}"; |
| 542 | + assertEquals("JSON was not alphabetically ordered or otherwise incorrect", expected, actual); |
| 543 | + } |
| 544 | + |
| 545 | + @Test |
| 546 | + public void testJsonOrderingOfAnAsset() throws Exception { |
| 547 | + Asset asset = new Asset(); |
| 548 | + |
| 549 | + Provider prov = new Provider(); |
| 550 | + prov.setName("IBM"); |
| 551 | + asset.setProvider(prov); |
| 552 | + |
| 553 | + WlpInformation wlpInformation = new WlpInformation(); |
| 554 | + wlpInformation.setVisibility(Visibility.INSTALL); |
| 555 | + wlpInformation.setDisplayPolicy(DisplayPolicy.HIDDEN); |
| 556 | + Collection<String> providesFeature = new ArrayList<String>(); |
| 557 | + providesFeature.add("my.feature-1.0"); |
| 558 | + wlpInformation.setProvideFeature(providesFeature); |
| 559 | + |
| 560 | + asset.setWlpInformation(wlpInformation); |
| 561 | + |
| 562 | + String actual = DataModelSerializer.serializeAsString(asset); |
| 563 | + String expected = "{\"provider\":{\"name\":\"IBM\"},\"wlpInformation\":{\"displayPolicy\":\"HIDDEN\",\"mainAttachmentSize\":0,\"provideFeature\":[\"my.feature-1.0\"]},\"wlpInformation2\":{\"visibility\":\"INSTALL\"}}"; |
| 564 | + |
| 565 | + assertEquals("JSON created from an asset was not in alphabetical order or otherwise incorrect", |
| 566 | + expected, actual); |
| 567 | + } |
| 568 | + |
514 | 569 | public static class LocaleTest {
|
515 | 570 | Locale locale;
|
516 | 571 |
|
|
0 commit comments