@Before
  public void setUp() {
    deviceClassResolverServiceMock = createMock(ScriptResolverService.class);

    deviceClassResolverService = new DeviceClassResolverServiceImpl();
    deviceClassResolverService.setDeviceClassScriptResolver(deviceClassResolverServiceMock);

    deviceClassResolverService.setResourceService(resourceServiceMock);
    deviceClassResolverService.setForceResolverValueService(forcedResolverValueService);
    deviceClassResolverService.setCacheResolverValueService(cacheResolverValueService);
  }
  @Test
  public void resolveDevice() {
    setNoForceNoCacheScenario();

    setUpResolveDeviceScenario(true, true);

    ResolverContext context = new ResolverContext(request, createSite(true));
    String deviceClass = deviceClassResolverService.getDeviceClass(context);

    assertEquals(RESOLVED_DEVICE_NAME, deviceClass);
  }
  @Test
  public void testForcedDeviceClass() {
    setForcedDeviceClassScenario();

    // Session variable there, but cookie should have precedence
    setUpCachedValue(DEVICE_CLASS_SESSION_VALUE);

    ResolverContext context = new ResolverContext(request, createSite(true));
    String deviceClass = deviceClassResolverService.getDeviceClass(context);
    assertEquals("Cookie-injected deviceClass should be used", NASTY_COOKIE_VALUE, deviceClass);
  }
  @Test
  public void testNotForcedNotCachedNoScript() {

    setNoForceNoCacheScenario();

    setUpResolveDeviceScenario(false, false);

    SiteEntity site = createSite(false);

    ResolverContext context = new ResolverContext(request, site);
    String deviceClass = deviceClassResolverService.getDeviceClass(context);

    assertEquals(null, deviceClass);
  }
  @Test
  public void testDefaultDeviceClass() {
    setUpGetResourceFileMock(true, true);

    expect(
            deviceClassResolverServiceMock.resolveValue(
                isA(ResolverContext.class), isA(ResourceFile.class)))
        .andReturn(createScriptResolverReturnValue(""))
        .times(1);
    replay(deviceClassResolverServiceMock);

    SiteEntity site = createSite(true);
    ResolverContext context = new ResolverContext(request, site);
    String deviceClass = deviceClassResolverService.getDeviceClass(context);

    assertEquals(DeviceClassResolverServiceImpl.DEFAULT_DEVICE_CLASS, deviceClass);
  }