ResolutionModifier implements CollectorJob { @Override public void setParameters(Map<String, String> params) throws ParametersException { if (params.containsKey(WIDTH_PARAM)) { width = NumberUtils.toInt(params.get(WIDTH_PARAM)); ParametersValidator.checkRange(width, 1, HEIGHT_MAX_SIZE, "Width should be greater than 0"); if (params.containsKey(HEIGHT_PARAM)) { setHeight(params); } else { setHeightSamplingPeriod(params); } } else { throw new ParametersException("You have to specify width, height parameter is optional"); } } ResolutionModifier(WebDriver webDriver, JavaScriptJobExecutor jsExecutor); @Override CollectorStepResult collect(); @Override void setParameters(Map<String, String> params); static final String NAME; }
@Test(expected = ParametersException.class) public void setParametersTest_widthNotANumber() throws ParametersException { when(params.containsKey(WIDTH_PARAM)).thenReturn(true); when(params.get(WIDTH_PARAM)).thenReturn(NOT_A_NUMBER); tested.setParameters(params); }
@Test(expected = ParametersException.class) public void setParametersTest_heightNotANumber() throws ParametersException { when(params.containsKey(HEIGHT_PARAM)).thenReturn(true); when(params.get(HEIGHT_PARAM)).thenReturn(NOT_A_NUMBER); tested.setParameters(params); }
@Test(expected = ParametersException.class) public void setParametersTest_width0() throws ParametersException { when(params.containsKey(WIDTH_PARAM)).thenReturn(true); when(params.get(WIDTH_PARAM)).thenReturn("0"); tested.setParameters(params); }
@Test(expected = ParametersException.class) public void setParametersTest_height0() throws ParametersException { when(params.containsKey(HEIGHT_PARAM)).thenReturn(true); when(params.get(HEIGHT_PARAM)).thenReturn("0"); tested.setParameters(params); }
@Test(expected = ParametersException.class) public void collectTest_setOnlyHeight() throws ParametersException { when(params.containsKey(HEIGHT_PARAM)).thenReturn(true); when(params.get(HEIGHT_PARAM)).thenReturn("" + CUSTOM_HEIGHT); tested.setParameters(params); }