@Override public TrackMe build() { if (mContentName == null || mContentName.length() == 0) { throw new IllegalArgumentException("Content name needs to be non-empty"); } if (mInteraction == null || mInteraction.length() == 0) { throw new IllegalArgumentException("Interaction name needs to be non-empty"); } return new TrackMe(getBaseTrackMe()) .set(QueryParams.CONTENT_NAME, mContentName) .set(QueryParams.CONTENT_PIECE, mContentPiece) .set(QueryParams.CONTENT_TARGET, mContentTarget) .set(QueryParams.CONTENT_INTERACTION, mInteraction); } }
@Test public void testTrackContentInteraction_invalid_name_empty() throws Exception { int errorCount = 0; try { track().interaction("", "test").piece("test").target("test2").build(); } catch (IllegalArgumentException e) { errorCount++; } try { track().interaction("test", "").piece("test").target("test2").build(); } catch (IllegalArgumentException e) { errorCount++; } try { track().interaction("", "").piece("test").target("test2").build(); } catch (IllegalArgumentException e) { errorCount++; } assertThat(errorCount, is(3)); }
@Test public void testTrackContentInteraction_invalid_name_null() throws Exception { int errorCount = 0; try { track().interaction(null, "test").piece("test").target("test2").build(); } catch (IllegalArgumentException e) { errorCount++; } try { track().interaction("test", null).piece("test").target("test2").build(); } catch (IllegalArgumentException e) { errorCount++; } try { track().interaction(null, null).piece("test").target("test2").build(); } catch (IllegalArgumentException e) { errorCount++; } assertThat(errorCount, is(3)); }
@Test public void testTrackContentInteraction_invalid_name_empty() throws Exception { int errorCount = 0; try { track().interaction("", "test").piece("test").target("test2").build(); } catch (IllegalArgumentException e) { errorCount++; } try { track().interaction("test", "").piece("test").target("test2").build(); } catch (IllegalArgumentException e) { errorCount++; } try { track().interaction("", "").piece("test").target("test2").build(); } catch (IllegalArgumentException e) { errorCount++; } assertThat(errorCount, is(3)); }
@Override public TrackMe build() { if (mContentName == null || mContentName.length() == 0) { throw new IllegalArgumentException("Content name needs to be non-empty"); } if (mInteraction == null || mInteraction.length() == 0) { throw new IllegalArgumentException("Interaction name needs to be non-empty"); } return new TrackMe(getBaseTrackMe()) .set(QueryParams.CONTENT_NAME, mContentName) .set(QueryParams.CONTENT_PIECE, mContentPiece) .set(QueryParams.CONTENT_TARGET, mContentTarget) .set(QueryParams.CONTENT_INTERACTION, mInteraction); } }
/** * Tracking the interactions<p> * To map an interaction to an impression make sure to set the same value for contentName and contentPiece as * the impression has. * * @param contentInteraction The name of the interaction with the content. For instance a 'click' * @param contentName The name of the content. For instance 'Ad Foo Bar' */ public ContentInteraction interaction(String contentName, String contentInteraction) { return new ContentInteraction(this, contentName, contentInteraction); }
/** * Tracking the interactions<p> * To map an interaction to an impression make sure to set the same value for contentName and contentPiece as * the impression has. * * @param contentInteraction The name of the interaction with the content. For instance a 'click' * @param contentName The name of the content. For instance 'Ad Foo Bar' */ public ContentInteraction interaction(String contentName, String contentInteraction) { return new ContentInteraction(this, contentName, contentInteraction); }
@Test public void testTrackContentInteraction_invalid_name_null() throws Exception { int errorCount = 0; try { track().interaction(null, "test").piece("test").target("test2").build(); } catch (IllegalArgumentException e) { errorCount++; } try { track().interaction("test", null).piece("test").target("test2").build(); } catch (IllegalArgumentException e) { errorCount++; } try { track().interaction(null, null).piece("test").target("test2").build(); } catch (IllegalArgumentException e) { errorCount++; } assertThat(errorCount, is(3)); }