Context { public void setBackgroundMode(BackgroundMode backgroundMode) { this.backgroundMode = backgroundMode; if (backgroundMode != null) { if (backgroundMode == BackgroundMode.Task) { tracker.setParam(Hit.HitParam.BackgroundMode.stringValue(), "task", new ParamOption().setPersistent(true)); } else { tracker.unsetParam(Hit.HitParam.BackgroundMode.stringValue()); } } } Context(Tracker tracker); int getLevel2(); String getLevel2String(); BackgroundMode getBackgroundMode(); void setLevel2(int level2); void setLevel2(String level2); void setBackgroundMode(BackgroundMode backgroundMode);  }
@Test public void setBackgroundModeTest() { context.setBackgroundMode(Context.BackgroundMode.Task); assertEquals(0, buffer.getVolatileParams().size()); assertEquals(1, buffer.getPersistentParams().size()); assertEquals(1, buffer.getPersistentParams().get("bg").getValues().size()); assertEquals("task", buffer.getPersistentParams().get("bg").getValues().get(0).execute()); }
@Test public void unsetBackgroundModeTest() { context.setBackgroundMode(Context.BackgroundMode.Task); context.setBackgroundMode(Context.BackgroundMode.Normal); assertEquals(0, buffer.getPersistentParams().size()); assertEquals(0, buffer.getVolatileParams().size()); }