use of au.com.dius.pact.core.support.json.JsonValue in project pact-jvm by DiUS.
the class PactDslJsonBodyTest method largeBodyTest.
@Test
public void largeBodyTest() {
PactDslJsonBody metadata = new PactDslJsonBody().stringType("origin", "product-data").datetimeExpression("dateCreated", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
PactDslJsonBody title = new PactDslJsonBody().stringType("mainTitle", "Lorem ipsum dolor sit amet, consectetur adipiscing elit").stringType("webTitle", "sample_data").minArrayLike("attributes", 1).stringType("key", "sample_data").stringType("value", "sample_data").closeObject().closeArray().asBody();
PactDslJsonBody description = new PactDslJsonBody().stringType("longDescription", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Tellus pellentesque eu tincidunt tortor aliquam nulla facilisi cras. Nunc sed id semper risus in. Sit amet consectetur adipiscing elit pellentesque. Gravida neque convallis a cras. Auctor augue mauris augue neque gravida. Lectus quam id leo in vitae turpis massa sed elementum. Quisque sagittis purus sit amet volutpat consequat. Interdum velit euismod in pellentesque massa. Eu scelerisque felis imperdiet proin fermentum leo. Vel orci porta non pulvinar neque laoreet suspendisse. Netus et malesuada fames ac turpis egestas maecenas pharetra convallis. Sagittis aliquam malesuada bibendum arcu vitae. Risus in hendrerit gravida rutrum. Varius duis at consectetur lorem donec massa sapien. Platea dictumst quisque sagittis purus sit amet volutpat. Dui sapien eget mi proin sed libero enim. Tincidunt praesent semper feugiat nibh sed pulvinar. Sollicitudin tempor id eu nisl nunc mi. Hac habitasse platea dictumst vestibulum rhoncus.").stringType("shortDescription", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Tellus pellentesque eu tincidunt tortor aliquam nulla facilisi cras. Nunc sed id semper risus in. Sit amet consectetur adipiscing elit pellentesque. Gravida neque convallis a cras. Auctor augue mauris augue neque gravida. Lectus quam id leo in vitae turpis massa sed elementum. Quisque sagittis purus sit amet volutpat consequat. Interdum velit euismod in pellentesque massa. Eu scelerisque felis imperdiet proin fermentum leo. Vel orci porta non pulvinar neque laoreet suspendisse. Netus et malesuada fames ac turpis egestas maecenas pharetra convallis. Sagittis aliquam malesuada bibendum arcu vitae. Risus in hendrerit gravida rutrum. Varius duis at consectetur lorem donec massa sapien. Platea dictumst quisque sagittis purus sit amet volutpat. Dui sapien eget mi proin sed libero enim.").minArrayLike("attributes", 1).stringType("key", "sample_data").stringType("value", "sample_data").closeObject().closeArray().asBody();
PactDslJsonBody productSpecification = new PactDslJsonBody().integerType("multiPackQuantity", 1).booleanType("copyrightInd", false).stringType("copyrightDets", "sample_data").booleanType("batteryRequired", true).booleanType("batteryIncluded", false).booleanType("beabApproved", false).stringType("beabCertNo", "sample_data").booleanType("plugRequired", false).booleanType("plugIncluded", false).booleanType("bulbRequired", false).booleanType("bulbIncluded", false).decimalType("voltage", 10.10).decimalType("wattage", 10.10);
PactDslJsonBody dimensions = new PactDslJsonBody().decimalType("length", 10.10).decimalType("width", 10.10).decimalType("height", 10.10).decimalType("pileHeight", 10.10).stringType("uom", "METRE");
PactDslJsonBody brand = new PactDslJsonBody().stringType("name", "sample_data");
PactDslJsonBody eventHistories = new PactDslJsonBody().stringType("eventService", "fam-service").datetimeExpression("eventCreationDate", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").stringType("eventType", "UPDATE").datetimeExpression("eventProcessedDate", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
PactDslJsonBody colours = new PactDslJsonBody().stringType("name", "sample_data").booleanType("primary", false).stringType("colourCode", "sample_data").stringType("hexCode", "sample_data").stringType("rgbCode", "sample_data");
PactDslJsonBody images = new PactDslJsonBody().stringType("name", "sample_data").stringType("linkType", "URI").stringType("uri", "153-7908284-BOK434X.jpg").stringType("description", "sample_data").stringType("type", "sample_data").stringType("status", "sample_data").minArrayLike("attributes", 1).stringType("key", "channelFormat").stringType("value", "X").closeObject().closeArray().asBody();
PactDslJsonBody caseDimensions = new PactDslJsonBody().decimalType("length", 10.10).decimalType("width", 10.10).decimalType("height", 10.10).decimalType("weight", 10.10).stringType("lwhUom", "MILLIMETRE").stringType("weightUom", "GRAM");
DslPart body = new PactDslJsonBody().object("metadata", metadata).integerType("version", 1).object("wrapper").stringType("w", "17f78aqr").minArrayLike("identifiers", 1).stringType("alias", "sku").minArrayLike("value", 1, PactDslJsonRootValue.stringType("7908284"), 1).closeArray().asBody().minArrayLike("aliases", 1, PactDslJsonRootValue.stringType("17f78aqr"), 1).closeObject().asBody().stringType("itemType", "ITEM").object("parentWrapper").stringType("p", "xf7kabqd").minArrayLike("identifiers", 1).stringType("alias", "sku").minArrayLike("value", 1, PactDslJsonRootValue.stringType("135325620.P"), 1).closeArray().asBody().minArrayLike("aliases", 1, PactDslJsonRootValue.stringType("xf7kabqd"), 1).closeObject().asBody().object("master").stringType("source", "PDS").object("title", title).object("description", description).object("brand", brand).object("productSpecification", productSpecification).minArrayLike("attributes", 1).stringType("scope", "DESCRIPTIVE").stringType("key", "sample_data").minArrayLike("values", 1, PactDslJsonRootValue.stringType("sample_data"), 1).closeObject().closeArray().asBody().minArrayLike("colours", 1, colours).object("weightsAndMeasures").object("dimensions", dimensions).object("weight").decimalType("weight", 10.10).decimalType("netWeight", 10.10).decimalType("catchWeight", 10.10).decimalType("pileWeight", 10.10).stringType("uom", "KILOGRAM").closeObject().asBody().object("volume").decimalType("liquidVolume", 10.10).stringType("uom", "LITRE").closeObject().asBody().object("scannedData").datetimeExpression("fileTimestamp", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").decimalType("averageWeight", 10.10).stringType("averageWeightUom", "GRAM").object("shipmentCase", caseDimensions).object("vendorCase", caseDimensions).closeObject().asBody().closeObject().asBody().minArrayLike("packages", 1).integerType("packageType", 1).object("weightsAndMeasures").object("dimensions", dimensions).object("weight").decimalType("weight", 10.10).decimalType("netWeight", 10.10).decimalType("catchWeight", 10.10).decimalType("pileWeight", 10.10).stringType("uom", "KILOGRAM").closeObject().asBody().object("volume").decimalType("liquidVolume", 10.10).stringType("uom", "LITRE").closeObject().asBody().object("scannedData").datetimeExpression("fileTimestamp", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").decimalType("averageWeight", 10.10).stringType("averageWeightUom", "GRAM").object("shipmentCase", caseDimensions).object("vendorCase", caseDimensions).closeObject().asBody().closeObject().asBody().closeObject().closeArray().asBody().object("media").minArrayLike("images", 1, images).closeObject().asBody().object("safety").booleanType("ageRestrictedFlag", false).booleanType("safetyIndicator", false).booleanType("safetyIndicatorFlag", false).booleanType("safetyIndicatorOverrideFlag", false).closeObject().asBody().object("waste").stringType("wasteType", "sample_data").decimalType("percentage", 10.10).decimalType("defaultPercentage", 10.10).datetimeExpression("effectiveFromDate", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").datetimeExpression("effectiveToDate", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").minArrayLike("attributes", 1).stringType("key", "associatedProductNumber").stringType("value", "sample_data").closeObject().closeArray().asBody().closeObject().asBody().object("optionalTypes").object("jewellery").decimalType("totalWeight", 10.10).decimalType("metalWeight", 10.10).decimalType("stoneWeight", 10.10).decimalType("chainLength", 10.10).stringType("ringSize", "sample_data").stringType("ringSizeFrom", "sample_data").stringType("ringSizeTo", "sample_data").closeObject().asBody().object("clothing").stringType("size", "sample_data").closeObject().asBody().eachLike("batteries", 0).closeArray().asBody().closeObject().asBody().object("productDataAudit").datetimeExpression("createdDate", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").datetimeExpression("lastModifiedDate", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").stringType("lastModifiedBy", "argos-pim-backfeed-adapter-service").datetimeExpression("deletedDate", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").closeObject().asBody().closeObject().asBody().object("division").stringType("masterSource", "DIV").object("title", title).object("description", description).object("brand", brand).object("productSpecification", productSpecification).minArrayLike("attributes", 1).stringType("scope", "DESCRIPTIVE").stringType("key", "sample_data").minArrayLike("values", 1, PactDslJsonRootValue.stringType("sample_data"), 1).closeObject().closeArray().asBody().minArrayLike("colours", 1, colours).object("weightsAndMeasures").object("dimensions", dimensions).object("weight").decimalType("weight", 10.10).decimalType("netWeight", 10.10).decimalType("catchWeight", 10.10).decimalType("pileWeight", 10.10).stringType("uom", "KILOGRAM").closeObject().asBody().object("volume").decimalType("liquidVolume", 10.10).stringType("uom", "LITRE").closeObject().asBody().object("scannedData").datetimeExpression("fileTimestamp", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").decimalType("averageWeight", 10.10).stringType("averageWeightUom", "GRAM").object("shipmentCase", caseDimensions).object("vendorCase", caseDimensions).closeObject().asBody().closeObject().asBody().minArrayLike("packages", 1).integerType("packageType", 1).object("weightsAndMeasures").object("dimensions", dimensions).object("weight").decimalType("weight", 10.10).decimalType("netWeight", 10.10).decimalType("catchWeight", 10.10).decimalType("pileWeight", 10.10).stringType("uom", "KILOGRAM").closeObject().asBody().object("volume").decimalType("liquidVolume", 10.10).stringType("uom", "LITRE").closeObject().asBody().object("scannedData").datetimeExpression("fileTimestamp", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").decimalType("averageWeight", 10.10).stringType("averageWeightUom", "GRAM").object("shipmentCase", caseDimensions).object("vendorCase", caseDimensions).closeObject().asBody().closeObject().asBody().closeObject().closeArray().asBody().object("media").minArrayLike("images", 1, images).closeObject().asBody().object("safety").booleanType("ageRestrictedFlag", false).booleanType("safetyIndicator", false).booleanType("safetyIndicatorFlag", false).booleanType("safetyIndicatorOverrideFlag", false).closeObject().asBody().object("waste").stringType("wasteType", "sample_data").decimalType("percentage", 10.10).decimalType("defaultPercentage", 10.10).datetimeExpression("effectiveFromDate", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").datetimeExpression("effectiveToDate", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").minArrayLike("attributes", 1).stringType("key", "weeeAssociatedProductNumber").stringType("value", "sample_data").closeObject().closeArray().asBody().closeObject().asBody().object("optionalTypes").object("jewellery").decimalType("totalWeight", 10.10).decimalType("metalWeight", 10.10).decimalType("stoneWeight", 10.10).decimalType("chainLength", 10.10).stringType("ringSize", "sample_data").stringType("ringSizeFrom", "sample_data").stringType("ringSizeTo", "sample_data").closeObject().asBody().object("clothing").stringType("size", "sample_data").closeObject().asBody().eachLike("batteries", 0).closeArray().asBody().closeObject().asBody().object("productDataAudit").datetimeExpression("createdDate", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").datetimeExpression("lastModifiedDate", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").stringType("lastModifiedBy", "bam").datetimeExpression("deletedDate", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").closeObject().asBody().closeObject().asBody().object("exxer").stringType("masterSource", "EXXER").closeObject().asBody().object("itemAudit").datetimeExpression("createdDate", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").datetimeExpression("lastModifiedDate", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").stringType("lastModifiedBy", "bam").minArrayLike("eventHistories", 1, eventHistories).closeObject().asBody();
JsonValue jsonValue = body.getBody();
assertThat(jsonValue.asObject().getEntries().keySet(), is(equalTo(new HashSet<>(Arrays.asList("division", "metadata", "itemType", "itemAudit", "exxer", "wrapper", "parentWrapper", "version", "master")))));
assertThat(jsonValue.asObject().get("itemAudit").asObject().getEntries().keySet(), is(equalTo(new HashSet<>(Arrays.asList("createdDate", "eventHistories", "lastModifiedBy", "lastModifiedDate")))));
assertThat(jsonValue.asObject().get("itemAudit").get("eventHistories").asArray().getValues().get(0).asObject().getEntries().keySet(), is(equalTo(new HashSet<>(Arrays.asList("eventProcessedDate", "eventType", "eventService", "eventCreationDate")))));
}
use of au.com.dius.pact.core.support.json.JsonValue in project pact-jvm by DiUS.
the class Defect464Test method runTest.
@Test
@PactVerification(PROVIDER_NAME)
public void runTest() throws IOException {
String jsonString = Request.get(provider.getUrl() + PROVIDER_URI).execute().returnContent().asString();
JsonValue root = JsonParser.parseString(jsonString);
JsonValue.Array myArrayElement = root.asObject().get(JSON_ARRAY_MEMBER_NAME).asArray();
List<ElementOfMyArray> myArray = myArrayElement.getValues().stream().map(e -> new ElementOfMyArray(e.get("id").asString())).collect(Collectors.toList());
List<String> ids = new ArrayList<>();
for (ElementOfMyArray elementOfMyArray : myArray) {
String elementOfMyArrayId = elementOfMyArray.getId();
Assert.assertFalse("Id " + elementOfMyArrayId + " is already known.", ids.contains(elementOfMyArrayId));
ids.add(elementOfMyArrayId);
}
}
Aggregations