@Override public TrackMe build() { if (mContentName == null || mContentName.length() == 0) { throw new IllegalArgumentException("Tracking content impressions requires a non-empty content-name"); } return new TrackMe(getBaseTrackMe()) .set(QueryParams.CONTENT_NAME, mContentName) .set(QueryParams.CONTENT_PIECE, mContentPiece) .set(QueryParams.CONTENT_TARGET, mContentTarget); } }
@Test public void testTrackContentImpression() throws Exception { String name = "test name2"; track().impression(name).piece("test").target("test2").with(mTracker); verify(mTracker).track(mCaptor.capture()); assertEquals(mCaptor.getValue().get(QueryParams.CONTENT_NAME), name); assertEquals(mCaptor.getValue().get(QueryParams.CONTENT_PIECE), "test"); assertEquals(mCaptor.getValue().get(QueryParams.CONTENT_TARGET), "test2"); }
@Test(expected = IllegalArgumentException.class) public void testTrackContentImpression_invalid_name_null() throws Exception { track().impression(null).build(); }
@Test(expected = IllegalArgumentException.class) public void testTrackContentImpression_invalid_name_null() throws Exception { track().impression(null).build(); }
@Test(expected = IllegalArgumentException.class) public void testTrackContentImpression_invalid_name_empty() throws Exception { track().impression("").build(); }
@Test(expected = IllegalArgumentException.class) public void testTrackContentImpression_invalid_name_empty() throws Exception { track().impression("").build(); }
/** * Tracking the impressions * * @param contentName The name of the content. For instance 'Ad Foo Bar' */ public ContentImpression impression(String contentName) { return new ContentImpression(this, contentName); }
/** * Tracking the impressions * * @param contentName The name of the content. For instance 'Ad Foo Bar' */ public ContentImpression impression(String contentName) { return new ContentImpression(this, contentName); }
@Test public void testTrackContentImpression() throws Exception { String name = "test name2"; track().impression(name).piece("test").target("test2").with(mTracker); verify(mTracker).track(mCaptor.capture()); assertEquals(mCaptor.getValue().get(QueryParams.CONTENT_NAME), name); assertEquals(mCaptor.getValue().get(QueryParams.CONTENT_PIECE), "test"); assertEquals(mCaptor.getValue().get(QueryParams.CONTENT_TARGET), "test2"); }
@Override public TrackMe build() { if (mContentName == null || mContentName.length() == 0) { throw new IllegalArgumentException("Tracking content impressions requires a non-empty content-name"); } return new TrackMe(getBaseTrackMe()) .set(QueryParams.CONTENT_NAME, mContentName) .set(QueryParams.CONTENT_PIECE, mContentPiece) .set(QueryParams.CONTENT_TARGET, mContentTarget); } }