當前位置: 首頁>>代碼示例>>Java>>正文


Java BidRequest類代碼示例

本文整理匯總了Java中com.google.openrtb.OpenRtb.BidRequest的典型用法代碼示例。如果您正苦於以下問題:Java BidRequest類的具體用法?Java BidRequest怎麽用?Java BidRequest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BidRequest類屬於com.google.openrtb.OpenRtb包,在下文中一共展示了BidRequest類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: writeBidRequest

import com.google.openrtb.OpenRtb.BidRequest; //導入依賴的package包/類
/**
 * Serializes a {@link BidRequest} to JSON, returned as a {@code String}.
 */
public String writeBidRequest(BidRequest req) throws IOException {
  try (StringWriter writer = new StringWriter()) {
    writeBidRequest(req, writer);
    return writer.toString();
  }
}
 
開發者ID:google,項目名稱:openrtb,代碼行數:10,代碼來源:OpenRtbJsonWriter.java

示例2: impWithId

import com.google.openrtb.OpenRtb.BidRequest; //導入依賴的package包/類
/**
 * Finds an {@link Imp} by ID.
 *
 * @return The {@link Imp}s that has the given id, or {@code null} if not found.
 */
@Nullable public static Imp impWithId(BidRequest request, String id) {
  checkNotNull(id);

  for (Imp imp : request.getImpList()) {
    if (imp.getId().equals(id)) {
      return imp;
    }
  }

  return null;
}
 
開發者ID:google,項目名稱:openrtb,代碼行數:17,代碼來源:OpenRtbUtils.java

示例3: bannerImpWithId

import com.google.openrtb.OpenRtb.BidRequest; //導入依賴的package包/類
/**
 * Find an {@link Imp} by its ID and its {@link Banner}'s ID.
 *
 * @param impId Imp ID; optional if the Banner IDs are unique within the request
 * @param bannerId Banner ID
 * @return The {@link Imp} for a given impression ID x banner ID, or {@code null} if not found
 */
@Nullable public static Imp bannerImpWithId(
    BidRequest request, @Nullable String impId, String bannerId) {
  checkNotNull(bannerId);

  for (Imp imp : request.getImpList()) {
    if ((impId == null || imp.getId().equals(impId))
        && imp.hasBanner() && imp.getBanner().getId().equals(bannerId)) {
      return imp;
    }
  }

  return null;
}
 
開發者ID:google,項目名稱:openrtb,代碼行數:21,代碼來源:OpenRtbUtils.java

示例4: testRequest_5_1_1

import com.google.openrtb.OpenRtb.BidRequest; //導入依賴的package包/類
@Test
public void testRequest_5_1_1() {
  BidRequest.newBuilder()
      .setId("1234534625254")
      .setAt(AuctionType.SECOND_PRICE)
      .setTmax(120)
      .addImp(Imp.newBuilder()
          .setId("1")
          .setBanner(Banner.newBuilder()
              .setW(300)
              .setH(250)
              .setPos(AdPosition.ABOVE_THE_FOLD)
              .addBattr(CreativeAttribute.USER_INTERACTIVE)))
       .addBadv("company1.com")
       .addBadv("company2.com")
       .setSite(Site.newBuilder()
           .setId("234563")
           .setName("Site ABCD")
           .setDomain("siteabcd.com")
           .addAllCat(asList("IAB2-1", "IAB2-2"))
           .setPrivacypolicy(true)
           .setPage("http://siteabcd.com/page.htm")
           .setRef("http://referringsite.com/referringpage.htm")
           .setPublisher(Publisher.newBuilder()
               .setId("pub12345")
               .setName("Publisher A"))
           .setContent(Content.newBuilder()
               .setKeywords("keyword a,keyword b,keyword c")))
       .setDevice(Device.newBuilder()
           .setIp("64.124.253.1")
           .setUa("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.16)")
           .setOs("OS X")
           .setFlashver("10.1")
           .setJs(true))
       .setUser(User.newBuilder()
           .setId("45asdf987656789adfad4678rew656789")
           .setBuyeruid("5df678asd8987656asdf78987654"))
   .build();
}
 
開發者ID:google,項目名稱:openrtb,代碼行數:40,代碼來源:ProtobufTest.java

示例5: testJsonFactory

import com.google.openrtb.OpenRtb.BidRequest; //導入依賴的package包/類
@Test
public void testJsonFactory() {
  assertThat(OpenRtbJsonFactory.create().getJsonFactory()).isNotNull();
  JsonFactory jf = new JsonFactory();
  assertThat(OpenRtbJsonFactory.create().setJsonFactory(jf).getJsonFactory()).isSameAs(jf);
  TestUtil.testCommonMethods(new Test2Reader<BidRequest.Builder>(TestExt.testRequest2, "x"));
  TestUtil.testCommonMethods(new Test4Writer());
}
 
開發者ID:google,項目名稱:openrtb,代碼行數:9,代碼來源:OpenRtbJsonTest.java

示例6: testRequest_AlternateFields

import com.google.openrtb.OpenRtb.BidRequest; //導入依賴的package包/類
@Test
public void testRequest_AlternateFields() throws IOException {
  testRequest(newJsonFactory()
      .register(new OpenRtbJsonExtWriter<Test1>() {
        @Override protected void write(Test1 ext, JsonGenerator gen) throws IOException {
          gen.writeStringField("test1", "data1");
          gen.writeStringField("test2", "data2");
          gen.writeStringField("test1", "data1");
          gen.writeStringField("test2", "data2");
        }
      }, Test1.class, BidRequest.class),
      newBidRequest().build());
}
 
開發者ID:google,項目名稱:openrtb,代碼行數:14,代碼來源:OpenRtbJsonTest.java

示例7: testRequest_emptyMessages

import com.google.openrtb.OpenRtb.BidRequest; //導入依賴的package包/類
@SuppressWarnings("deprecation")
@Test
public void testRequest_emptyMessages() throws IOException {
  OpenRtbJsonFactory jsonFactory = newJsonFactory();
  testRequest(jsonFactory, BidRequest.newBuilder().setId("0").build());
  testRequest(jsonFactory, BidRequest.newBuilder().setId("0")
      .addImp(Imp.newBuilder().setId("0"))
      .setDevice(Device.newBuilder())
      .setApp(App.newBuilder())
      .setUser(User.newBuilder())
      .setRegs(Regs.newBuilder())
      .build());
  testRequest(jsonFactory, BidRequest.newBuilder().setId("0")
      .addImp(Imp.newBuilder().setId("0")
          .setBanner(Banner.newBuilder())
          .setPmp(Pmp.newBuilder()))
      .addImp(Imp.newBuilder().setId("0")
          .setBanner(Banner.newBuilder()
              .addFormat(Banner.Format.newBuilder())))
      .setDevice(Device.newBuilder().setGeo(Geo.newBuilder()))
      .setSite(Site.newBuilder())
      .setUser(User.newBuilder().addData(Data.newBuilder()))
      .build());
  testRequest(jsonFactory, BidRequest.newBuilder().setId("0")
      .addImp(Imp.newBuilder().setId("0")
          .setVideo(Video.newBuilder())
          .setAudio(Audio.newBuilder())
          .setPmp(Pmp.newBuilder().addDeals(Pmp.Deal.newBuilder().setId("0"))))
      .addImp(Imp.newBuilder().setId("0")
          .setVideo(Video.newBuilder().setCompanionad21(Video.CompanionAd.newBuilder())))
      .setSite(Site.newBuilder()
          .setContent(Content.newBuilder())
          .setPublisher(Publisher.newBuilder()))
          .setUser(User.newBuilder().addData(Data.newBuilder().addSegment(Segment.newBuilder())))
      .build());
  testRequest(jsonFactory, BidRequest.newBuilder().setId("0")
      .setSite(Site.newBuilder()
          .setContent(Content.newBuilder().setProducer(Producer.newBuilder())))
      .build());
}
 
開發者ID:google,項目名稱:openrtb,代碼行數:41,代碼來源:OpenRtbJsonTest.java

示例8: testRequest_extNoReadersRegistered

import com.google.openrtb.OpenRtb.BidRequest; //導入依賴的package包/類
@Test
public void testRequest_extNoReadersRegistered() throws IOException {
  OpenRtbJsonReader reader = OpenRtbJsonFactory.create().newReader();
  BidRequest req = BidRequest.newBuilder().setId("0").build();
  // Based on Issue #34
  assertThat(reader.readBidRequest("{ \"ext\": { \"x\": 0 }, \"id\": \"0\" }")).isEqualTo(req);
}
 
開發者ID:google,項目名稱:openrtb,代碼行數:8,代碼來源:OpenRtbJsonTest.java

示例9: testRequest_extNoReadersConsume

import com.google.openrtb.OpenRtb.BidRequest; //導入依賴的package包/類
@Test
public void testRequest_extNoReadersConsume() throws IOException {
  OpenRtbJsonReader reader = newJsonFactory().newReader();
  BidRequest req = BidRequest.newBuilder().setId("0").build();
  // Based on Issue #34
  assertThat(reader.readBidRequest("{ \"ext\": { \"x\": { } }, \"id\": \"0\" }")).isEqualTo(req);
}
 
開發者ID:google,項目名稱:openrtb,代碼行數:8,代碼來源:OpenRtbJsonTest.java

示例10: testRequest_extBug

import com.google.openrtb.OpenRtb.BidRequest; //導入依賴的package包/類
@Test
public void testRequest_extBug() throws IOException {
  OpenRtbJsonReader reader = OpenRtbJsonFactory.create().newReader();
  BidRequest req = BidRequest.newBuilder().setId("0").build();
  // Based on Issue #34
  assertThat(reader.readBidRequest("{ \"ext\": { \"x\": 0, \"y\": {} }, \"id\": \"0\" }"))
      .isEqualTo(req);
}
 
開發者ID:google,項目名稱:openrtb,代碼行數:9,代碼來源:OpenRtbJsonTest.java

示例11: testExt2Scalar

import com.google.openrtb.OpenRtb.BidRequest; //導入依賴的package包/類
@Test
public void testExt2Scalar() throws IOException {
  OpenRtbJsonFactory jsonFactory = newJsonFactory();
  testRequest(jsonFactory, BidRequest.newBuilder()
      .setId("0")
      .setExtension(TestExt.testRequest2, test2)
      .build());
}
 
開發者ID:google,項目名稱:openrtb,代碼行數:9,代碼來源:OpenRtbJsonTest.java

示例12: testIgnoredFields

import com.google.openrtb.OpenRtb.BidRequest; //導入依賴的package包/類
@Test
public void testIgnoredFields() throws IOException {
  String test =
        "{ \"id\": \"0\", "
      + "\"x1\": 10, \"at\": 1, "
      + "\"x2\": \"x\", \"x3\": [4], \"test\": 1, "
      + "\"x4\": { \"x5\": [] }, \"tmax\": 100, "
      + "\"ext\": { \"x6\": [ { \"x7\": 100, \"x8\": 3.1415 } ], \"test1\": \"*\" }"
      + "}";
  assertThat(newJsonFactory().newReader().readBidRequest(test))
      .isEqualTo(BidRequest.newBuilder()
          .setId("0")
          .setAt(AuctionType.FIRST_PRICE)
          .setTest(true)
          .setTmax(100)
          .setExtension(TestExt.testRequest1, Test1.newBuilder().setTest1("*").build())
          .build());
}
 
開發者ID:google,項目名稱:openrtb,代碼行數:19,代碼來源:OpenRtbJsonTest.java

示例13: testKeywordsAsArray

import com.google.openrtb.OpenRtb.BidRequest; //導入依賴的package包/類
@Test
public void testKeywordsAsArray() throws IOException {
  String test =
         "{ \"id\": \"0\",\n  \"site\": { \"content\": { "
      + "\"keywords\":  [\"foo\", \"bar\"]},\n \"id\": \"56600\",\n \"cat\": [\"IAB19\"],\n "
      + "\"keywords\": \"\",\n \"name\": \"Emoji Free!\",\n \"ver\": null\n } \n}";
  BidRequest bidRequest = newJsonFactory().newReader().readBidRequest(test);
  assertThat(bidRequest.getSite().getContent().getKeywords()).isEqualTo("foo,bar");
}
 
開發者ID:google,項目名稱:openrtb,代碼行數:10,代碼來源:OpenRtbJsonTest.java

示例14: testRequest

import com.google.openrtb.OpenRtb.BidRequest; //導入依賴的package包/類
static void testRequest(OpenRtbJsonFactory jsonFactory, BidRequest req) throws IOException {
  String jsonReq = jsonFactory.newWriter().writeBidRequest(req);
  logger.info(jsonReq);
  jsonFactory.setStrict(false).newWriter().writeBidRequest(req);
  BidRequest req2 = jsonFactory.newReader().readBidRequest(jsonReq);
  assertThat(req2).isEqualTo(req);
  jsonFactory.setStrict(false).newReader().readBidRequest(jsonReq);
}
 
開發者ID:google,項目名稱:openrtb,代碼行數:9,代碼來源:OpenRtbJsonTest.java

示例15: testRequestWithNative

import com.google.openrtb.OpenRtb.BidRequest; //導入依賴的package包/類
static void testRequestWithNative(
    String input, String result,
    boolean rootNative, boolean nativeAsObject, boolean ignoreIdField) throws IOException {
  OpenRtbJsonFactory jsonFactory = newJsonFactory().setForceNativeAsObject(nativeAsObject);
  OpenRtb.BidRequest bidRequest = jsonFactory.newReader().readBidRequest(input);
  String jsonRequestNativeStr =
      jsonFactory.setRootNativeField(rootNative).newWriter().writeBidRequest(bidRequest);
  ObjectMapper mapper = new ObjectMapper();
  Object json = mapper.readValue(jsonRequestNativeStr, Object.class);
  jsonRequestNativeStr = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(json);

  if (ignoreIdField) {
    assertThat(cleanupIdField(jsonRequestNativeStr)).isEqualTo(cleanupIdField(result));
  } else {
    assertThat(jsonRequestNativeStr).isEqualTo(result);
  }
}
 
開發者ID:google,項目名稱:openrtb,代碼行數:18,代碼來源:OpenRtbJsonTest.java


注:本文中的com.google.openrtb.OpenRtb.BidRequest類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。