org.skyscreamer.jsonassert.JSONCompareMode Java Examples

The following examples show how to use org.skyscreamer.jsonassert.JSONCompareMode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IntegrationTest.java    From jsonschema-generator with Apache License 2.0 6 votes vote down vote up
/**
 * Test
 *
 * @throws Exception
 */
@Test
public void testIntegration() throws Exception {
    // active all optional modules
    JavaxValidationModule module = new JavaxValidationModule(
            JavaxValidationOption.NOT_NULLABLE_FIELD_IS_REQUIRED,
            JavaxValidationOption.NOT_NULLABLE_METHOD_IS_REQUIRED,
            JavaxValidationOption.INCLUDE_PATTERN_EXPRESSIONS);
    SchemaGeneratorConfig config = new SchemaGeneratorConfigBuilder(new ObjectMapper(), SchemaVersion.DRAFT_2019_09)
            .with(module)
            .build();
    SchemaGenerator generator = new SchemaGenerator(config);
    JsonNode result = generator.generateSchema(TestClass.class);

    String rawJsonSchema = result.toString();
    JSONAssert.assertEquals('\n' + rawJsonSchema + '\n',
            loadResource("integration-test-result.json"), rawJsonSchema, JSONCompareMode.STRICT);
}
 
Example #2
Source File: ApplicationTest.java    From prebid-server-java with Apache License 2.0 6 votes vote down vote up
@Test
public void vtrackShouldReturnJsonWithUids() throws JSONException, IOException {
    // given and when
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cache"))
            .withRequestBody(equalToJson(jsonFrom("vtrack/test-cache-request.json"), true, false))
            .willReturn(aResponse().withBody(jsonFrom("vtrack/test-vtrack-response.json"))));

    final Response response = given(SPEC)
            .when()
            .body(jsonFrom("vtrack/test-vtrack-request.json"))
            .queryParam("a", "14062")
            .post("/vtrack");

    // then
    JSONAssert.assertEquals("{\"responses\":[{\"uuid\":\"94531ab8-c662-4fc7-904e-6b5d3be43b1a\"}]}",
            response.asString(), JSONCompareMode.NON_EXTENSIBLE);
}
 
Example #3
Source File: ValidatePublishArtifactConfigExecutorTest.java    From docker-registry-artifact-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldValidateRequestWithBuildFile() throws Exception {
    String requestBody = new JSONObject().put("BuildFile", "").toString();
    when(request.requestBody()).thenReturn(requestBody);

    final GoPluginApiResponse response = new ValidatePublishArtifactConfigExecutor(request).execute();

    String expectedJSON = "[" +
            "  {" +
            "    'key': 'BuildFile'," +
            "    'message': 'Either `Image` or `BuildFile` should be specified.'" +
            "  }," +
            "  {" +
            "    'key': 'Image'," +
            "    'message': 'Either `Image` or `BuildFile` should be specified.'" +
            "  }" +
            "]";
    JSONAssert.assertEquals(expectedJSON, response.responseBody(), JSONCompareMode.NON_EXTENSIBLE);
}
 
Example #4
Source File: ValidateArtifactStoreConfigExecutorExecutorTest.java    From docker-registry-artifact-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldValidatePresenceOfUsernameAndPasswordIfTypeIsOther() throws JSONException {
    String requestBody = new JSONObject()
            .put("RegistryURL", "http://localhost/index")
            .put("RegistryType", "other")
            .toString();
    when(request.requestBody()).thenReturn(requestBody);

    final GoPluginApiResponse response = new ValidateArtifactStoreConfigExecutor(request).execute();
    String expectedJSON = "[\n" +
            "  {\n" +
            "    \"key\": \"Username\",\n" +
            "    \"message\": \"Username must not be blank.\"\n" +
            "  },\n" +
            "  {\n" +
            "    \"key\": \"Password\",\n" +
            "    \"message\": \"Password must not be blank.\"\n" +
            "  }\n" +
            "]";
    JSONAssert.assertEquals(expectedJSON, response.responseBody(), JSONCompareMode.NON_EXTENSIBLE);
}
 
Example #5
Source File: ValidateArtifactStoreConfigExecutorExecutorTest.java    From docker-registry-artifact-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldValidatePresenceOfAwsRegionIfTypeIsEcr() throws JSONException {
    String requestBody = new JSONObject()
            .put("RegistryType", "ecr")
            .toString();
    when(request.requestBody()).thenReturn(requestBody);

    final GoPluginApiResponse response = new ValidateArtifactStoreConfigExecutor(request).execute();
    String expectedJSON = "[\n" +
            "  {\n" +
            "    \"key\": \"AWSRegion\",\n" +
            "    \"message\": \"AWSRegion must not be blank.\"\n" +
            "  },\n" +
            "  {\n" +
            "    \"key\": \"RegistryID\",\n" +
            "    \"message\": \"RegistryID must not be blank.\"\n" +
            "  }\n" +
            "]";
    JSONAssert.assertEquals(expectedJSON, response.responseBody(), JSONCompareMode.NON_EXTENSIBLE);
}
 
Example #6
Source File: IntegrationTest.java    From jsonschema-generator with Apache License 2.0 6 votes vote down vote up
@Test
@Parameters
public void testIntegration(Class<?> rawTargetType) throws Exception {
    Swagger2Module module = new Swagger2Module();
    SchemaGeneratorConfigBuilder configBuilder = new SchemaGeneratorConfigBuilder(SchemaVersion.DRAFT_2019_09, OptionPreset.PLAIN_JSON)
            .with(Option.DEFINITIONS_FOR_ALL_OBJECTS)
            .with(Option.NONSTATIC_NONVOID_NONGETTER_METHODS, Option.FIELDS_DERIVED_FROM_ARGUMENTFREE_METHODS)
            .with(module);
    SchemaGenerator generator = new SchemaGenerator(configBuilder.build());
    JsonNode result = generator.generateSchema(rawTargetType);

    String rawJsonSchema = result.toString();
    JSONAssert.assertEquals('\n' + rawJsonSchema + '\n',
            loadResource("integration-test-result-" + rawTargetType.getSimpleName() + ".json"), rawJsonSchema,
            JSONCompareMode.STRICT);
}
 
Example #7
Source File: SchemaGeneratorSubtypesTest.java    From jsonschema-generator with Apache License 2.0 6 votes vote down vote up
@Test
@Parameters
@TestCaseName(value = "{method}({0}) [{index}]")
public void testGenerateSchema(String caseTitle, List<Class<?>> subtypes, SchemaVersion schemaVersion) throws Exception {
    SchemaGeneratorConfigBuilder configBuilder = new SchemaGeneratorConfigBuilder(new ObjectMapper(), schemaVersion, OptionPreset.PLAIN_JSON)
            .with(Option.DEFINITIONS_FOR_ALL_OBJECTS, Option.NULLABLE_FIELDS_BY_DEFAULT);
    configBuilder.forTypesInGeneral()
            .withSubtypeResolver(new TestSubtypeResolver(subtypes))
            .withTitleResolver(TypeScope::getSimpleTypeDescription)
            .withDescriptionResolver(scope -> scope.getType().getErasedType() == TestSuperClass.class ? "supertype-only description" : null);
    if (!subtypes.isEmpty()) {
        configBuilder.forFields()
                .withTargetTypeOverridesResolver(this::determineTargetTypeOverrides);
    }
    SchemaGenerator generator = new SchemaGenerator(configBuilder.build());

    JsonNode result = generator.generateSchema(TestClassWithSuperTypeReferences.class);
    JSONAssert.assertEquals('\n' + result.toString() + '\n',
            TestUtils.loadResource(SchemaGeneratorSubtypesTest.class, caseTitle + ".json"), result.toString(), JSONCompareMode.STRICT);
}
 
Example #8
Source File: SchemaGeneratorCustomDefinitionsTest.java    From jsonschema-generator with Apache License 2.0 6 votes vote down vote up
@Test
@Parameters(source = SchemaVersion.class)
public void testGenerateSchema_CircularCustomStandardDefinition(SchemaVersion schemaVersion) throws Exception {
    String accessProperty = "get(0)";
    CustomDefinitionProviderV2 customDefinitionProvider = (javaType, context) -> {
        if (!javaType.isInstanceOf(List.class)) {
            return null;
        }
        ResolvedType generic = context.getTypeContext().getContainerItemType(javaType);
        SchemaGeneratorConfig config = context.getGeneratorConfig();
        return new CustomDefinition(config.createObjectNode()
                .put(config.getKeyword(SchemaKeyword.TAG_TYPE), config.getKeyword(SchemaKeyword.TAG_TYPE_OBJECT))
                .set(config.getKeyword(SchemaKeyword.TAG_PROPERTIES), config.createObjectNode()
                        .set(accessProperty, context.createDefinitionReference(generic))));
    };
    SchemaGeneratorConfigBuilder configBuilder = new SchemaGeneratorConfigBuilder(schemaVersion);
    configBuilder.forTypesInGeneral()
            .withCustomDefinitionProvider(customDefinitionProvider);
    SchemaGenerator generator = new SchemaGenerator(configBuilder.build());
    JsonNode result = generator.generateSchema(TestCircularClass1.class);
    JSONAssert.assertEquals('\n' + result.toString() + '\n',
            TestUtils.loadResource(this.getClass(), "circular-custom-definition-" + schemaVersion.name() + ".json"),
            result.toString(), JSONCompareMode.STRICT);
}
 
Example #9
Source File: SubtypeResolutionIntegrationTest.java    From jsonschema-generator with Apache License 2.0 6 votes vote down vote up
@Test
public void testIntegration() throws Exception {
    JacksonModule module = new JacksonModule(JacksonOption.FLATTENED_ENUMS_FROM_JSONVALUE);
    SchemaGeneratorConfig config = new SchemaGeneratorConfigBuilder(new ObjectMapper(), SchemaVersion.DRAFT_2019_09, OptionPreset.PLAIN_JSON)
            .with(Option.DEFINITIONS_FOR_ALL_OBJECTS, Option.NULLABLE_FIELDS_BY_DEFAULT)
            .with(module)
            .build();
    SchemaGenerator generator = new SchemaGenerator(config);
    JsonNode result = generator.generateSchema(TestClassForSubtypeResolution.class);

    String rawJsonSchema = result.toString();
    JSONAssert.assertEquals('\n' + rawJsonSchema + '\n',
            loadResource("subtype-integration-test-result.json"), rawJsonSchema, JSONCompareMode.STRICT);

    JsonSchema schemaForValidation = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909).getSchema(result);
    String jsonInstance = config.getObjectMapper().writeValueAsString(new TestClassForSubtypeResolution());

    Set<ValidationMessage> validationResult = schemaForValidation.validate(config.getObjectMapper().readTree(jsonInstance));
    if (!validationResult.isEmpty()) {
        Assert.fail("\n" + jsonInstance + "\n  " + validationResult.stream()
                .map(ValidationMessage::getMessage)
                .collect(Collectors.joining("\n  ")));
    }
}
 
Example #10
Source File: AdopplerTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
@Test
public void openrtb2AuctionShouldRespondWithBidsFromAdoppler() throws IOException, JSONException {
    // given
    // Adoppler bid response for imp 001
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/adoppler-exchange/processHeaderBid/unit1"))
            .withHeader("Accept", equalTo("application/json"))
            .withHeader("Content-Type", equalTo("application/json;charset=UTF-8"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/adoppler/test-adoppler-bid-request-1.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/adoppler/test-adoppler-bid-response-1.json"))));

    // pre-bid cache
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cache"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/adoppler/test-cache-adoppler-request.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/adoppler/test-cache-adoppler-response.json"))));

    // when
    final Response response = given(SPEC)
            .header("Referer", "http://www.example.com")
            .header("X-Forwarded-For", "193.168.244.1")
            .header("User-Agent", "userAgent")
            .header("Origin", "http://www.example.com")
            .cookie("uids", "eyJ1aWRzIjp7ImFkb3BwbGVyIjoiQVAtVUlEIn19")
            .body(jsonFrom("openrtb2/adoppler/test-auction-adoppler-request.json"))
            .post("/openrtb2/auction");

    // then
    final String expectedAuctionResponse = openrtbAuctionResponseFrom(
            "openrtb2/adoppler/test-auction-adoppler-response.json",
            response, singletonList("adoppler"));

    String actualStr = response.asString();
    JSONAssert.assertEquals(expectedAuctionResponse, actualStr, JSONCompareMode.NON_EXTENSIBLE);
}
 
Example #11
Source File: TappxTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
@Test
public void openrtb2AuctionShouldRespondWithBidsFromTappx() throws IOException, JSONException {
    // given
    // tappx bid response for imp 12
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/tappx-exchange"))
            .withQueryParam("tappxkey", equalTo("pub-12345-android-9876"))
            .withQueryParam("v", equalTo("1.1"))
            .withQueryParam("type_cnn", equalTo("prebid"))
            .withHeader("Content-Type", equalToIgnoreCase("application/json;charset=utf-8"))
            .withHeader("Accept", equalTo("application/json"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/tappx/test-tappx-bid-request.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/tappx/test-tappx-bid-response.json"))));

    // pre-bid cache
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cache"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/tappx/test-cache-tappx-request.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/tappx/test-cache-tappx-response.json"))));

    // when
    final Response response = given(SPEC)
            .header("Referer", "http://www.example.com")
            .header("X-Forwarded-For", "193.168.244.1")
            .header("User-Agent", "userAgent")
            .header("Origin", "http://www.example.com")
            // this uids cookie value stands for {"uids":{"tappx":"TX-UID"}}
            .cookie("uids", "eyJ1aWRzIjp7InRhcHB4IjoiVFgtVUlEIn19")
            .body(jsonFrom("openrtb2/tappx/test-auction-tappx-request.json"))
            .post("/openrtb2/auction");

    // then
    final String expectedAuctionResponse = openrtbAuctionResponseFrom(
            "openrtb2/tappx/test-auction-tappx-response.json",
            response, singletonList("tappx"));

    JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), JSONCompareMode.NON_EXTENSIBLE);
}
 
Example #12
Source File: GumgumTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
@Test
public void openrtb2AuctionShouldRespondWithBidsFromGumGum() throws IOException, JSONException {
    // given
    // GumGum bid response for imp 001 and 002
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/gumgum-exchange"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/gumgum/test-gumgum-bid-request-1.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/gumgum/test-gumgum-bid-response-1.json"))));

    // pre-bid cache
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cache"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/gumgum/test-cache-gumgum-request.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/gumgum/test-cache-gumgum-response.json"))));

    // when
    final Response response = given(SPEC)
            .header("Referer", "http://www.example.com")
            .header("X-Forwarded-For", "193.168.244.1")
            .header("User-Agent", "userAgent")
            .header("Origin", "http://www.example.com")
            // this uids cookie value stands for {"uids":{"gum":"GUM-UID"}}
            .cookie("uids", "eyJ1aWRzIjp7Imd1bSI6IkdVTS1VSUQifX0=")
            .body(jsonFrom("openrtb2/gumgum/test-auction-gumgum-request.json"))
            .post("/openrtb2/auction");

    // then
    final String expectedAuctionResponse = openrtbAuctionResponseFrom(
            "openrtb2/gumgum/test-auction-gumgum-response.json",
            response, singletonList("gumgum"));

    JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), JSONCompareMode.NON_EXTENSIBLE);
}
 
Example #13
Source File: ImprovedigitalTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
@Test
public void openrtb2AuctionShouldRespondWithBidsFromImproveDigital() throws IOException, JSONException {
    // given
    // Improvedigital bid response for imp 001
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/improvedigital-exchange"))
            .withRequestBody(equalToJson(
                    jsonFrom("openrtb2/improvedigital/test-improvedigital-bid-request-1.json")))
            .willReturn(aResponse().withBody(
                    jsonFrom("openrtb2/improvedigital/test-improvedigital-bid-response-1.json"))));

    // pre-bid cache
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cache"))
            .withRequestBody(equalToJson(
                    jsonFrom("openrtb2/improvedigital/test-cache-improvedigital-request.json")))
            .willReturn(aResponse().withBody(
                    jsonFrom("openrtb2/improvedigital/test-cache-improvedigital-response.json"))));

    // when
    final Response response = given(SPEC)
            .header("Referer", "http://www.example.com")
            .header("X-Forwarded-For", "193.168.244.1")
            .header("User-Agent", "userAgent")
            .header("Origin", "http://www.example.com")
            // this uids cookie value stands for {"uids":{"improvedigital":"ID-UID"}}
            .cookie("uids", "eyJ1aWRzIjp7ImltcHJvdmVkaWdpdGFsIjoiSUQtVUlEIn19")
            .body(jsonFrom("openrtb2/improvedigital/test-auction-improvedigital-request.json"))
            .post("/openrtb2/auction");

    // then
    final String expectedAuctionResponse = openrtbAuctionResponseFrom(
            "openrtb2/improvedigital/test-auction-improvedigital-response.json",
            response, singletonList("improvedigital"));

    JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), JSONCompareMode.NON_EXTENSIBLE);
}
 
Example #14
Source File: AdponeTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
@Test
public void openrtb2AuctionShouldRespondWithBidsFromAdpone() throws IOException, JSONException {
    // given
    // Adpone bid response for imp 001
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/adpone-exchange"))
            .withHeader("x-openrtb-version", equalTo("2.5"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/adpone/test-adpone-bid-request.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/adpone/test-adpone-bid-response.json"))));

    // pre-bid cache
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cache"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/adpone/test-cache-adpone-request.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/adpone/test-cache-adpone-response.json"))));

    // when
    final Response response = given(SPEC)
            .header("Referer", "http://www.example.com")
            .header("X-Forwarded-For", "193.168.244.1")
            .header("User-Agent", "userAgent")
            .header("Origin", "http://www.example.com")
            // this uids cookie value stands for {"uids":{"adpone":"AP-UID"}}
            .cookie("uids", "eyJ1aWRzIjp7ImFkcG9uZSI6IkFQLVVJRCJ9fQ==")
            .body(jsonFrom("openrtb2/adpone/test-auction-adpone-request.json"))
            .post("/openrtb2/auction");

    // then
    final String expectedAuctionResponse = openrtbAuctionResponseFrom(
            "openrtb2/adpone/test-auction-adpone-response.json",
            response, singletonList("adpone"));

    JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), JSONCompareMode.NON_EXTENSIBLE);
}
 
Example #15
Source File: MgidTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
@Test
public void openrtb2AuctionShouldRespondWithBidsFromTheMgid() throws IOException, JSONException {
    // given
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/mgid-exchange/123"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/mgid/test-mgid-bid-request.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/mgid/test-mgid-bid-response.json"))));

    // pre-bid cache
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cache"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/mgid/test-cache-mgid-request.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/mgid/test-cache-mgid-response.json"))));

    // when
    final Response response = given(SPEC)
            .header("Referer", "http://www.example.com")
            .header("X-Forwarded-For", "193.168.244.1")
            .header("User-Agent", "userAgent")
            .header("Origin", "http://www.example.com")
            // this uids cookie value stands for {"uids":{"mgid":"MGID-UID"}}
            .cookie("uids", "eyJ1aWRzIjp7Im1naWQiOiJNR0lELVVJRCJ9fQ==")
            .body(jsonFrom("openrtb2/mgid/test-auction-mgid-request.json"))
            .post("/openrtb2/auction");

    // then
    final String expectedAuctionResponse = openrtbAuctionResponseFrom(
            "openrtb2/mgid/test-auction-mgid-response.json",
            response, singletonList("mgid"));

    JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), JSONCompareMode.NON_EXTENSIBLE);
}
 
Example #16
Source File: TripleliftTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
@Test
public void openrtb2AuctionShouldRespondWithBidsFromTriplelift() throws IOException, JSONException {
    // given
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/triplelift-exchange"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/triplelift/test-triplelift-bid-request.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/triplelift/test-triplelift-bid-response.json"))));

    // pre-bid cache
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cache"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/triplelift/test-cache-triplelift-request.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/triplelift/test-cache-triplelift-response.json"))));

    // when
    final Response response = given(SPEC)
            .header("Referer", "http://www.example.com")
            .header("X-Forwarded-For", "193.168.244.1")
            .header("User-Agent", "userAgent")
            .header("Origin", "http://www.example.com")
            // this uids cookie value stands for {"uids":{"triplelift":"TL-UID"}}
            .cookie("uids", "eyJ1aWRzIjp7InRyaXBsZWxpZnQiOiJUTC1VSUQifX0=")
            .body(jsonFrom("openrtb2/triplelift/test-auction-triplelift-request.json"))
            .post("/openrtb2/auction");

    // then
    final String expectedAuctionResponse = openrtbAuctionResponseFrom(
            "openrtb2/triplelift/test-auction-triplelift-response.json",
            response, singletonList("triplelift"));
    final String actualStr = response.asString();
    JSONAssert.assertEquals(expectedAuctionResponse, actualStr, JSONCompareMode.NON_EXTENSIBLE);
}
 
Example #17
Source File: VisxTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
@Test
public void openrtb2AuctionShouldRespondWithBidsFromVisx() throws IOException, JSONException {
    // given
    // VisxTest bid response for imp 001
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/visx-exchange"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/visx/test-visx-bid-request.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/visx/test-visx-bid-response.json"))));

    // pre-bid cache
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cache"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/visx/test-cache-visx-request.json"), true, false))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/visx/test-cache-visx-response.json"))));

    // when
    final Response response = given(SPEC)
            .header("Referer", "http://www.example.com")
            .header("X-Forwarded-For", "193.168.244.1")
            .header("User-Agent", "userAgent")
            .header("Origin", "http://www.example.com")
            // this uids cookie value stands for {"uids":{"visx":"VISX-UID"}}
            .cookie("uids", "eyJ1aWRzIjp7InZpc3giOiJWSVNYLVVJRCJ9fQ==")
            .body(jsonFrom("openrtb2/visx/test-auction-visx-request.json"))
            .post("/openrtb2/auction");

    // then
    final String expectedAuctionResponse = openrtbAuctionResponseFrom(
            "openrtb2/visx/test-auction-visx-response.json",
            response, singletonList("visx"));

    JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), JSONCompareMode.NON_EXTENSIBLE);
}
 
Example #18
Source File: UnrulyTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
@Test
public void openrtb2AuctionShouldRespondWithBidsFromUnruly() throws IOException, JSONException {
    // given
    // Unruly bid response for imp 001
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/unruly-exchange"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/unruly/test-unruly-bid-request-1.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/unruly/test-unruly-bid-response-1.json"))));

    // Unruly bid response for imp 002
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/unruly-exchange"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/unruly/test-unruly-bid-request-2.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/unruly/test-unruly-bid-response-2.json"))));

    // pre-bid cache
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cache"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/unruly/test-cache-unruly-request.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/unruly/test-cache-unruly-response.json"))));

    // when
    final Response response = given(SPEC)
            .header("Referer", "http://www.example.com")
            .header("X-Forwarded-For", "193.168.244.1")
            .header("User-Agent", "userAgent")
            .header("Origin", "http://www.example.com")
            // this uids cookie value stands for {"uids":{"unruly":"UR-UID"}}
            .cookie("uids", "eyJ1aWRzIjp7InVucnVseSI6IlVSLVVJRCJ9fQ==")
            .body(jsonFrom("openrtb2/unruly/test-auction-unruly-request.json"))
            .post("/openrtb2/auction");

    // then
    final String expectedAuctionResponse = openrtbAuctionResponseFrom(
            "openrtb2/unruly/test-auction-unruly-response.json",
            response, singletonList("unruly"));

    JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), JSONCompareMode.NON_EXTENSIBLE);
}
 
Example #19
Source File: GamoshiTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
@Test
public void openrtb2AuctionShouldRespondWithBidsFromGamoshi() throws IOException, JSONException {
    // given
    // Gamoshi bid response for imp 001 and 002
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/gamoshi-exchange/r/1701/bidr"))
            .withQueryParam("bidder", equalTo("prebid-server"))
            .withHeader("Accept", equalTo("application/json"))
            .withHeader("Content-Type", equalTo("application/json;charset=UTF-8"))
            .withHeader("User-Agent", equalTo("userAgent"))
            .withHeader("X-Forwarded-For", equalTo("193.168.244.1"))
            .withHeader("Accept-Language", equalTo("en"))
            .withHeader("DNT", equalTo("2"))
            .withHeader("x-openrtb-version", equalTo("2.4"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/gamoshi/test-gamoshi-bid-request-1.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/gamoshi/test-gamoshi-bid-response-1.json"))));

    // pre-bid cache
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cache"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/gamoshi/test-cache-gamoshi-request.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/gamoshi/test-cache-gamoshi-response.json"))));

    // when
    final Response response = given(SPEC)
            .header("Referer", "http://www.example.com")
            .header("X-Forwarded-For", "193.168.244.1")
            .header("User-Agent", "userAgent")
            .header("Origin", "http://www.example.com")
            // this uids cookie value stands for {"uids":{"gamoshi":"GM-UID"}}
            .cookie("uids", "eyJ1aWRzIjp7ImdhbW9zaGkiOiJHTS1VSUQifX0=")
            .body(jsonFrom("openrtb2/gamoshi/test-auction-gamoshi-request.json"))
            .post("/openrtb2/auction");

    // then
    final String expectedAuctionResponse = openrtbAuctionResponseFrom(
            "openrtb2/gamoshi/test-auction-gamoshi-response.json",
            response, singletonList("gamoshi"));

    JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), JSONCompareMode.NON_EXTENSIBLE);
}
 
Example #20
Source File: MarsmediaTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
@Test
public void openrtb2AuctionShouldRespondWithBidsFromMarsmedia() throws IOException, JSONException {
    // given
    // Marsmedia bid response for imp 001
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/marsmedia-exchange&zone=zone_1"))
            //.withQueryParam("zone", equalTo("zone_1"))
            .withHeader("x-openrtb-version", equalTo("2.5"))
            .withHeader("DNT", equalTo("2"))
            .withHeader("Accept-Language", equalTo("en"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/marsmedia/test-marsmedia-bid-request-1.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/marsmedia/test-marsmedia-bid-response-1.json"))));

    // pre-bid cache
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cache"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/marsmedia/test-cache-marsmedia-request.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/marsmedia/test-cache-marsmedia-response.json"))));

    // when
    final Response response = given(SPEC)
            .header("Referer", "http://www.example.com")
            .header("X-Forwarded-For", "193.168.244.1")
            .header("User-Agent", "userAgent")
            .header("Origin", "http://www.example.com")
            // this uids cookie value stands for {"uids":{"marsmedia":"MM-UID"}}
            .cookie("uids", "eyJ1aWRzIjp7Im1hcnNtZWRpYSI6Ik1NLVVJRCJ9fQ==")
            .body(jsonFrom("openrtb2/marsmedia/test-auction-marsmedia-request.json"))
            .post("/openrtb2/auction");

    // then
    final String expectedAuctionResponse = openrtbAuctionResponseFrom(
            "openrtb2/marsmedia/test-auction-marsmedia-response.json",
            response, singletonList("marsmedia"));

    JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), JSONCompareMode.NON_EXTENSIBLE);
}
 
Example #21
Source File: LifestreetTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
@Test
public void openrtb2AuctionShouldRespondWithBidsFromLifestreet() throws IOException, JSONException {
    // given
    // lifestreet bid response for imp 7
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/lifestreet-exchange"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/lifestreet/test-lifestreet-bid-request-1.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/lifestreet/test-lifestreet-bid-response-1.json"))));

    // lifestreet bid response for imp 71
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/lifestreet-exchange"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/lifestreet/test-lifestreet-bid-request-2.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/lifestreet/test-lifestreet-bid-response-2.json"))));

    // pre-bid cache
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cache"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/lifestreet/test-cache-lifestreet-request.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/lifestreet/test-cache-lifestreet-response.json"))));

    // when
    final Response response = given(SPEC)
            .header("Referer", "http://www.example.com")
            .header("X-Forwarded-For", "193.168.244.1")
            .header("User-Agent", "userAgent")
            .header("Origin", "http://www.example.com")
            // this uids cookie value stands for {"uids":{"lifestreet":"LS-UID"}}
            .cookie("uids", "eyJ1aWRzIjp7ImxpZmVzdHJlZXQiOiJMUy1VSUQifX0=")
            .body(jsonFrom("openrtb2/lifestreet/test-auction-lifestreet-request.json"))
            .post("/openrtb2/auction");

    // then
    final String expectedAuctionResponse = openrtbAuctionResponseFrom(
            "openrtb2/lifestreet/test-auction-lifestreet-response.json",
            response, singletonList(LIFESTREET));

    JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), JSONCompareMode.NON_EXTENSIBLE);
}
 
Example #22
Source File: PulsepointTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
@Test
public void openrtb2AuctionShouldRespondWithBidsFromPulsepoint() throws IOException, JSONException {
    // given
    // pulsepoint bid response for imp 8
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/pulsepoint-exchange"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/pulsepoint/test-pulsepoint-bid-request-1.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/pulsepoint/test-pulsepoint-bid-response-1.json"))));

    // pre-bid cache
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cache"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/pulsepoint/test-cache-pulsepoint-request.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/pulsepoint/test-cache-pulsepoint-response.json"))));

    // when
    final Response response = given(SPEC)
            .header("Referer", "http://www.example.com")
            .header("X-Forwarded-For", "193.168.244.1")
            .header("User-Agent", "userAgent")
            .header("Origin", "http://www.example.com")
            // this uids cookie value stands for {"uids":{"pulsepoint":"PP-UID"}}
            .cookie("uids", "eyJ1aWRzIjp7InB1bHNlcG9pbnQiOiJQUC1VSUQifX0=")
            .body(jsonFrom("openrtb2/pulsepoint/test-auction-pulsepoint-request.json"))
            .post("/openrtb2/auction");

    // then
    final String expectedAuctionResponse = openrtbAuctionResponseFrom(
            "openrtb2/pulsepoint/test-auction-pulsepoint-response.json",
            response, singletonList(PULSEPOINT));

    JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), JSONCompareMode.NON_EXTENSIBLE);
}
 
Example #23
Source File: AppnexusVideoTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
@Test
public void openrtb2VideoShouldRespondWithBidsFromAppnexus() throws IOException, JSONException {
    // given
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/appnexus-exchange"))
            .withHeader("Content-Type", equalToIgnoreCase("application/json;charset=UTF-8"))
            .withHeader("Accept", equalTo("application/json"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/video/test-video-appnexus-bid-request-1.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/video/test-video-appnexus-bid-response-1.json"))));

    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/appnexus-exchange"))
            .withHeader("Content-Type", equalToIgnoreCase("application/json;charset=UTF-8"))
            .withHeader("Accept", equalTo("application/json"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/video/test-video-appnexus-bid-request-2.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/video/test-video-appnexus-bid-response-2.json"))));

    // pre-bid cache
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cache"))
            .withRequestBody(equalToJson(
                    jsonFrom("openrtb2/video/test-video-cache-request.json"), true, false))
            .willReturn(aResponse()
                    .withTransformers("cache-response-transformer")
                    .withTransformerParameter("matcherName",
                            "openrtb2/video/test-video-cache-response-matcher.json")));

    // when
    final Response response = given(SPEC)
            .header("Referer", "http://www.example.com")
            .header("X-Forwarded-For", "193.168.244.1")
            .header("User-Agent", "userAgent")
            .header("Origin", "http://www.example.com")
            .body(jsonFrom("openrtb2/video/test-video-appnexus-request.json"))
            .post("/openrtb2/video");

    // then
    // TODO remove "empty" when VideoRequest will proceed consentValue.
    final String expectedAuctionResponse = jsonFrom("openrtb2/video/test-video-appnexus-response-empty.json");

    JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), JSONCompareMode.NON_EXTENSIBLE);
}
 
Example #24
Source File: KubientTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
@Test
public void openrtb2AuctionShouldRespondWithBidsFromKubient() throws IOException, JSONException {
    // given
    // Kubient bid response for imp 001 and 002
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/kubient-exchange"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/kubient/test-kubient-bid-request-1.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/kubient/test-kubient-bid-response-1.json"))));

    // pre-bid cache
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cache"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/kubient/test-cache-kubient-request.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/kubient/test-cache-kubient-response.json"))));

    // when
    final Response response = given(SPEC)
            .header("Referer", "http://www.example.com")
            .header("X-Forwarded-For", "193.168.244.1")
            .header("User-Agent", "userAgent")
            .header("Origin", "http://www.example.com")
            // this uids cookie value stands for {"uids":{"kub":"KUM-UID"}}
            .cookie("uids", "eyJ1aWRzIjp7Imt1YiI6IktVTS1VSUQifX0=")
            .body(jsonFrom("openrtb2/kubient/test-auction-kubient-request.json"))
            .post("/openrtb2/auction");

    // then
    final String expectedAuctionResponse = openrtbAuctionResponseFrom(
            "openrtb2/kubient/test-auction-kubient-response.json",
            response, singletonList("kubient"));

    JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), JSONCompareMode.NON_EXTENSIBLE);
}
 
Example #25
Source File: ValueImpressionTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
@Test
public void openrtb2AuctionShouldRespondWithBidsFromValueImpression() throws IOException, JSONException {
    // given
    // ValueImpression bid response
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/valueimpression-exchange"))
            .withHeader("Accept", equalTo("application/json"))
            .withHeader("Content-Type", equalTo("application/json;charset=UTF-8"))
            .withRequestBody(
                    equalToJson(jsonFrom("openrtb2/valueimpression/test-valueimpression-bid-request-1.json")))
            .willReturn(aResponse()
                    .withBody(jsonFrom("openrtb2/valueimpression/test-valueimpression-bid-response-1.json"))));

    // pre-bid cache
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cache"))
            .withRequestBody(
                    equalToJson(jsonFrom("openrtb2/valueimpression/test-cache-valueimpression-request.json")))
            .willReturn(aResponse()
                    .withBody(jsonFrom("openrtb2/valueimpression/test-cache-valueimpression-response.json"))));

    // when
    final Response response = given(SPEC)
            .header("Referer", "http://www.example.com")
            .header("X-Forwarded-For", "193.168.244.1")
            .header("User-Agent", "userAgent")
            .header("Origin", "http://www.example.com")
            .cookie("uids", "eyJ1aWRzIjp7InZhbHVlaW1wcmVzc2lvbiI6IlZJLVVJRCJ9fQ==")
            .body(jsonFrom("openrtb2/valueimpression/test-auction-valueimpression-request.json"))
            .post("/openrtb2/auction");

    // then
    final String expectedAuctionResponse = openrtbAuctionResponseFrom(
            "openrtb2/valueimpression/test-auction-valueimpression-response.json",
            response, singletonList("valueimpression"));

    JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), JSONCompareMode.NON_EXTENSIBLE);
}
 
Example #26
Source File: YieldoneTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
@Test
public void openrtb2AuctionShouldRespondWithBidsFromYieldone() throws IOException, JSONException {
    // given
    // Yieldone bid response for imp 001
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/yieldone-exchange"))
            .withHeader("Accept", equalTo("application/json"))
            .withHeader("Content-Type", equalTo("application/json;charset=UTF-8"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/yieldone/test-yieldone-bid-request.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/yieldone/test-yieldone-bid-response.json"))));

    // pre-bid cache
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cache"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/yieldone/test-cache-yieldone-request.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/yieldone/test-cache-yieldone-response.json"))));

    // when
    final Response response = given(SPEC)
            .header("Referer", "http://www.example.com")
            .header("X-Forwarded-For", "193.168.244.1")
            .header("User-Agent", "userAgent")
            .header("Origin", "http://www.example.com")
            .cookie("uids", "eyJ1aWRzIjp7InlpZWxkb25lIjoiWUQtVUlEIn19")
            .body(jsonFrom("openrtb2/yieldone/test-auction-yieldone-request.json"))
            .post("/openrtb2/auction");

    // then
    final String expectedAuctionResponse = openrtbAuctionResponseFrom(
            "openrtb2/yieldone/test-auction-yieldone-response.json",
            response, singletonList("yieldone"));

    JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), JSONCompareMode.NON_EXTENSIBLE);
}
 
Example #27
Source File: SonobiTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
@Test
public void openrtb2AuctionShouldRespondWithBidsFromSonobi() throws IOException, JSONException {
    // given
    // Sonobi bid response for imp 001
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/sonobi-exchange"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/sonobi/test-sonobi-bid-request-1.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/sonobi/test-sonobi-bid-response-1.json"))));

    // Sonobi bid response for imp 002
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/sonobi-exchange"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/sonobi/test-sonobi-bid-request-2.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/sonobi/test-sonobi-bid-response-2.json"))));

    // pre-bid cache
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cache"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/sonobi/test-cache-sonobi-request.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/sonobi/test-cache-sonobi-response.json"))));

    // when
    final Response response = given(SPEC)
            .header("Referer", "http://www.example.com")
            .header("X-Forwarded-For", "193.168.244.1")
            .header("User-Agent", "userAgent")
            .header("Origin", "http://www.example.com")
            // this uids cookie value stands for {"uids":{"sonobi":"SB-UID"}}
            .cookie("uids", "eyJ1aWRzIjp7InNvbm9iaSI6IlNCLVVJRCJ9fQ==")
            .body(jsonFrom("openrtb2/sonobi/test-auction-sonobi-request.json"))
            .post("/openrtb2/auction");

    // then
    final String expectedAuctionResponse = openrtbAuctionResponseFrom(
            "openrtb2/sonobi/test-auction-sonobi-response.json",
            response, singletonList("sonobi"));

    JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), JSONCompareMode.NON_EXTENSIBLE);
}
 
Example #28
Source File: ApplogyTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
@Test
public void openrtb2AuctionShouldRespondWithBidsFromApplogy() throws IOException, JSONException {
    // given
    // Applogy bid response for imp 001
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/applogy-exchange/1234"))
            .withHeader("Accept", equalTo("application/json"))
            .withHeader("Content-Type", equalTo("application/json;charset=UTF-8"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/applogy/test-applogy-bid-request-1.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/applogy/test-applogy-bid-response-1.json"))));

    // Applogy bid response for imp 002
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/applogy-exchange/12345"))
            .withHeader("Accept", equalTo("application/json"))
            .withHeader("Content-Type", equalTo("application/json;charset=UTF-8"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/applogy/test-applogy-bid-request-2.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/applogy/test-applogy-bid-response-2.json"))));

    // pre-bid cache
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cache"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/applogy/test-cache-applogy-request.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/applogy/test-cache-applogy-response.json"))));

    // when
    final Response response = given(SPEC)
            .header("Referer", "http://www.example.com")
            .header("X-Forwarded-For", "193.168.244.1")
            .header("User-Agent", "userAgent")
            .header("Origin", "http://www.example.com")
            .cookie("uids", "eyJ1aWRzIjp7ImdhbW9zaGkiOiJHTS1VSUQifX0=")
            .body(jsonFrom("openrtb2/applogy/test-auction-applogy-request.json"))
            .post("/openrtb2/auction");

    // then
    final String expectedAuctionResponse = openrtbAuctionResponseFrom(
            "openrtb2/applogy/test-auction-applogy-response.json",
            response, singletonList("applogy"));

    JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), JSONCompareMode.NON_EXTENSIBLE);
}
 
Example #29
Source File: EmxdigitalTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
@Test
public void openrtb2AuctionShouldRespondWithBidsFromEmxdigital() throws IOException, JSONException {
    // given
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/emx_digital-exchange"))
            .withQueryParam("t", equalTo("1000"))
            .withQueryParam("ts", equalTo("2060541160"))
            .withHeader("Accept", equalTo("application/json"))
            .withHeader("Content-Type", equalToIgnoreCase("application/json;charset=utf-8"))
            .withHeader("User-Agent", equalTo("Android Chrome/60"))
            .withHeader("X-Forwarded-For", equalTo("127.0.0.1"))
            .withHeader("Referer", equalTo("http://www.example.com"))
            .withHeader("DNT", equalTo("2"))
            .withHeader("Accept-Language", equalTo("en"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/emxdigital/test-emxdigital-bid-request.json"),
                    true, true))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/emxdigital/test-emxdigital-bid-response.json"))));

    // pre-bid cache
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cache"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/emxdigital/test-cache-emxdigital-request.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/emxdigital/test-cache-emxdigital-response.json"))));

    // when
    final Response response = given(SPEC)
            .header("Referer", "http://www.example.com")
            .header("X-Forwarded-For", "193.168.244.1")
            .header("User-Agent", "userAgent")
            .header("Origin", "http://www.example.com")
            // this uids cookie value stands for {"uids":{"emxdigital":"STR-UID"}}
            .cookie("uids", "eyJ1aWRzIjp7ImVteGRpZ2l0YWwiOiJTVFItVUlEIn19")
            .body(jsonFrom("openrtb2/emxdigital/test-auction-emxdigital-request.json"))
            .post("/openrtb2/auction");

    // then
    final String expectedAuctionResponse = openrtbAuctionResponseFrom(
            "openrtb2/emxdigital/test-auction-emxdigital-response.json",
            response, singletonList("emx_digital"));

    JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), JSONCompareMode.NON_EXTENSIBLE);
}
 
Example #30
Source File: TtxTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
@Test
public void openrtb2AuctionShouldRespondWithBidsFrom33Across() throws IOException, JSONException {
    // given
    // 33Across bid response for imp 001
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/ttx-exchange"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/ttx/test-ttx-bid-request-1.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/ttx/test-ttx-bid-response-1.json"))));

    // pre-bid cache
    WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cache"))
            .withRequestBody(equalToJson(jsonFrom("openrtb2/ttx/test-cache-ttx-request.json")))
            .willReturn(aResponse().withBody(jsonFrom("openrtb2/ttx/test-cache-ttx-response.json"))));

    // when
    final Response response = given(SPEC)
            .header("Referer", "http://www.example.com")
            .header("X-Forwarded-For", "193.168.244.1")
            .header("User-Agent", "userAgent")
            .header("Origin", "http://www.example.com")
            // this uids cookie value stands for {"uids":{"33across":"TTX-UID"}}
            .cookie("uids", "eyJ1aWRzIjp7IjMzYWNyb3NzIjoiVFRYLVVJRCJ9fQ==")
            .body(jsonFrom("openrtb2/ttx/test-auction-ttx-request.json"))
            .post("/openrtb2/auction");

    // then
    final String expectedAuctionResponse = openrtbAuctionResponseFrom(
            "openrtb2/ttx/test-auction-ttx-response.json",
            response, singletonList("ttx"));

    JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), JSONCompareMode.NON_EXTENSIBLE);
}