@Test public void givenJson_shouldDeserialiseToMagazine() throws MalformedURLException { Magazine expectedMagazine = new Magazine(); expectedMagazine.setId("ABCD-1234"); expectedMagazine.setTitle("Fun with Java"); expectedMagazine.setAuthor(new Author("Alex", "Theedom")); expectedMagazine.setPrice(45.00f); expectedMagazine.setPages(300); expectedMagazine.setInPrint(true); expectedMagazine.setBinding(Binding.SOFT_BACK); expectedMagazine.setLanguages(Arrays.asList("French", "English", "Spanish", null)); expectedMagazine.setWebsite(new URL("https: expectedMagazine.setInternalAuditCode(null); expectedMagazine.setPublished(LocalDate.parse("01/01/2018", DateTimeFormatter.ofPattern("MM/dd/yyyy"))); expectedMagazine.setAlternativeTitle(null); ComprehensiveExample comprehensiveExample = new ComprehensiveExample(); Magazine actualMagazine = comprehensiveExample.deserialiseMagazine(); assertThat(actualMagazine).isEqualTo(expectedMagazine); }
public Magazine deserialiseMagazine() { String json = "{\"author\":{\"firstName\":\"Alex\",\"lastName\":\"Theedom\"},\"binding\":\"SOFT_BACK\",\"id\":\"ABCD-1234\",\"inPrint\":true,\"languages\":[\"French\",\"English\",\"Spanish\",null],\"pages\":300,\"price\":45.0,\"published\":\"2018-01-01\",\"title\":\"Fun with Java\",\"website\":\"https: return JsonbBuilder.create().fromJson(json, Magazine.class); }
ComprehensiveExample { public Magazine deserialiseMagazine() { String json = "{\"author\":{\"firstName\":\"Alex\",\"lastName\":\"Theedom\"},\"binding\":\"SOFT_BACK\",\"id\":\"ABCD-1234\",\"inPrint\":true,\"languages\":[\"French\",\"English\",\"Spanish\",null],\"pages\":300,\"price\":45.0,\"published\":\"2018-01-01\",\"title\":\"Fun with Java\",\"website\":\"https: return JsonbBuilder.create().fromJson(json, Magazine.class); } }
ComprehensiveExample { public Magazine deserialiseMagazine() { String json = "{\"author\":{\"firstName\":\"Alex\",\"lastName\":\"Theedom\"},\"binding\":\"SOFT_BACK\",\"id\":\"ABCD-1234\",\"inPrint\":true,\"languages\":[\"French\",\"English\",\"Spanish\",null],\"pages\":300,\"price\":45.0,\"published\":\"2018-01-01\",\"title\":\"Fun with Java\",\"website\":\"https: return JsonbBuilder.create().fromJson(json, Magazine.class); }  }
ComprehensiveExample { public Magazine deserialiseMagazine() { String json = "{\"author\":{\"firstName\":\"Alex\",\"lastName\":\"Theedom\"},\"binding\":\"SOFT_BACK\",\"id\":\"ABCD-1234\",\"inPrint\":true,\"languages\":[\"French\",\"English\",\"Spanish\",null],\"pages\":300,\"price\":45.0,\"published\":\"2018-01-01\",\"title\":\"Fun with Java\",\"website\":\"https: return JsonbBuilder.create().fromJson(json, Magazine.class); }  String serialiseMagazine(); Magazine deserialiseMagazine(); }
ComprehensiveExample { public Magazine deserialiseMagazine() { String json = "{\"author\":{\"firstName\":\"Alex\",\"lastName\":\"Theedom\"},\"binding\":\"SOFT_BACK\",\"id\":\"ABCD-1234\",\"inPrint\":true,\"languages\":[\"French\",\"English\",\"Spanish\",null],\"pages\":300,\"price\":45.0,\"published\":\"2018-01-01\",\"title\":\"Fun with Java\",\"website\":\"https: return JsonbBuilder.create().fromJson(json, Magazine.class); }  String serialiseMagazine(); Magazine deserialiseMagazine();  }