ComparisonController { @RequestMapping(value = COMPARE_PATH, method = RequestMethod.POST) public ComparisonStateTokens getCompareStateTokens(@RequestBody final ComparisonRequest<Q> body) throws E { final int STATE_TOKEN_MAX_RESULTS = comparisonService.getStateTokenMaxResults(); final String firstStateToken = body.getFirstQueryStateToken() != null ? body.getFirstQueryStateToken() : documentsService.getStateToken(body.getFirstRestrictions(), STATE_TOKEN_MAX_RESULTS, false); final String secondStateToken = body.getSecondQueryStateToken() != null ? body.getSecondQueryStateToken() : documentsService.getStateToken(body.getSecondRestrictions(), STATE_TOKEN_MAX_RESULTS, false); return comparisonService.getCompareStateTokens(firstStateToken, secondStateToken); } @Autowired  ComparisonController(final ComparisonService<R, E> comparisonService, final DocumentsService<?, ?, ?, Q, R, E> documentsService); @RequestMapping(value = COMPARE_PATH, method = RequestMethod.POST) ComparisonStateTokens getCompareStateTokens(@RequestBody final ComparisonRequest<Q> body); @SuppressWarnings("MethodWithTooManyParameters") @RequestMapping(value = RESULTS_PATH, method = RequestMethod.GET) Documents<R> getResults(
            @RequestParam(STATE_MATCH_PARAM) final List<String> stateMatchIds,
            @RequestParam(value = STATE_DONT_MATCH_PARAM, required = false) final List<String> stateDontMatchIds,
            @RequestParam(value = TEXT_PARAM, required = false, defaultValue = "*") final String text,
            @RequestParam(value = FIELD_TEXT_PARAM, defaultValue = "") final String fieldText,
            @RequestParam(value = RESULTS_START_PARAM, required = false, defaultValue = "1") final int resultsStart,
            @RequestParam(MAX_RESULTS_PARAM) final int maxResults,
            @RequestParam(SUMMARY_PARAM) final String summary,
            @RequestParam(value = SORT_PARAM, required = false) final String sort,
            @RequestParam(value = HIGHLIGHT_PARAM, required = false, defaultValue = "true") final boolean highlight,
            @RequestParam(value = PROMOTIONS, defaultValue = "false") final boolean promotions
    );  }
@Test public void compareStateTokens() throws AciErrorException { final ComparisonRequest<IdolQueryRestrictions> comparisonRequest = new Builder<IdolQueryRestrictions>() .setFirstQueryStateToken(MOCK_STATE_TOKEN_1) .setSecondQueryStateToken(MOCK_STATE_TOKEN_2) .build(); comparisonController.getCompareStateTokens(comparisonRequest); verify(comparisonService).getCompareStateTokens(eq(MOCK_STATE_TOKEN_1), eq(MOCK_STATE_TOKEN_2)); }
@Test public void compareTokenAndRestriction() throws AciErrorException { final ComparisonRequest<IdolQueryRestrictions> comparisonRequest = new Builder<IdolQueryRestrictions>() .setFirstQueryStateToken(MOCK_STATE_TOKEN_1) .setSecondRestrictions(queryRestrictions) .build(); comparisonController.getCompareStateTokens(comparisonRequest); verify(comparisonService).getCompareStateTokens(eq(MOCK_STATE_TOKEN_1), eq(MOCK_STATE_TOKEN_1)); }
@Test public void compareRestrictionAndToken() throws AciErrorException { final ComparisonRequest<IdolQueryRestrictions> comparisonRequest = new Builder<IdolQueryRestrictions>() .setFirstRestrictions(queryRestrictions) .setSecondQueryStateToken(MOCK_STATE_TOKEN_2) .build(); comparisonController.getCompareStateTokens(comparisonRequest); verify(comparisonService).getCompareStateTokens(eq(MOCK_STATE_TOKEN_1), eq(MOCK_STATE_TOKEN_2)); }
@Test public void compareRestrictions() throws AciErrorException { final ComparisonRequest<IdolQueryRestrictions> comparisonRequest = new Builder<IdolQueryRestrictions>() .setFirstRestrictions(queryRestrictions) .setSecondRestrictions(queryRestrictions) .build(); comparisonController.getCompareStateTokens(comparisonRequest); verify(comparisonService).getCompareStateTokens(eq(MOCK_STATE_TOKEN_1), eq(MOCK_STATE_TOKEN_1)); }