RawMessageUtils { public static <M extends Message> boolean matches(M testMsg, M matchMsg) { return matches(testMsg, matchMsg, null); }  static boolean matches(M testMsg, M matchMsg);  }
@Test public void testMatchScalar() { BidRequest matchMsg = BidRequest.newBuilder().setAllimps(true).buildPartial(); assertTrue(RawMessageUtils.matches( BidRequest.newBuilder().setAllimps(true).buildPartial(), matchMsg)); assertFalse(RawMessageUtils.matches( BidRequest.newBuilder().setAllimps(false).buildPartial(), matchMsg)); assertFalse(RawMessageUtils.matches( BidRequest.newBuilder().buildPartial(), matchMsg)); }
@Test public void testMatchRepeated() { BidRequest matchMsg = BidRequest.newBuilder().addAllBcat(asList( ContentCategory.IAB1, ContentCategory.IAB2, ContentCategory.IAB3)).buildPartial(); assertTrue(RawMessageUtils.matches( BidRequest.newBuilder().addAllBcat(asList( ContentCategory.IAB1, ContentCategory.IAB2, ContentCategory.IAB3, ContentCategory.IAB4)) .buildPartial(), matchMsg)); assertFalse(RawMessageUtils.matches( BidRequest.newBuilder().addAllBcat(asList( ContentCategory.IAB1, ContentCategory.IAB2, ContentCategory.IAB4, ContentCategory.IAB5)) .buildPartial(), matchMsg)); assertFalse(RawMessageUtils.matches( BidRequest.newBuilder().buildPartial(), matchMsg)); }
@Test public void testMatchMessage() { BidRequest matchMsg = BidRequest.newBuilder() .setUser(User.newBuilder().setId("A").buildPartial()).buildPartial(); assertTrue(RawMessageUtils.matches( BidRequest.newBuilder().setUser( User.newBuilder().setId("A").addKeywords("X").buildPartial()).buildPartial(), matchMsg)); assertFalse(RawMessageUtils.matches( BidRequest.newBuilder().setUser( User.newBuilder().setId("B").addKeywords("X").buildPartial()).buildPartial(), matchMsg)); assertFalse(RawMessageUtils.matches( BidRequest.newBuilder().setUser( User.newBuilder().addKeywords("X").buildPartial()).buildPartial(), matchMsg)); assertFalse(RawMessageUtils.matches( BidRequest.newBuilder().buildPartial(), matchMsg)); }
@Test public void testMatchRepeatedMessage() { Imp i = Imp.newBuilder().setId("1").setInstl(true).buildPartial(); Imp i1 = Imp.newBuilder().setId("1").setInstl(true).setTagid("X").buildPartial(); Imp i2 = Imp.newBuilder().setId("1").setInstl(false).setTagid("X").buildPartial(); Imp i3 = Imp.newBuilder().setId("1").setTagid("X").buildPartial(); BidRequest matchMsg = BidRequest.newBuilder().addImp(i).buildPartial(); assertTrue(RawMessageUtils.matches( BidRequest.newBuilder().addAllImp(asList(i1, i2)).buildPartial(), matchMsg)); assertFalse(RawMessageUtils.matches( BidRequest.newBuilder().addAllImp(asList(i2, i3)).buildPartial(), matchMsg)); assertFalse(RawMessageUtils.matches( BidRequest.newBuilder().buildPartial(), matchMsg)); }