@Test public void testGetPolicies() throws ControlPointApiException { final List<ControlPointPolicy> policies = Arrays.asList( new ControlPointPolicy("1", "archive", true, true), new ControlPointPolicy("2", "delete", true, true), new ControlPointPolicy("3", "preserve", false, true), new ControlPointPolicy("4", "process", true, false), new ControlPointPolicy("5", "redirect", false, false) ); Mockito.when(cpService.getPolicies()).thenReturn(new ControlPointPolicies(policies)); final List<ControlPointPolicy> result = controller.getPolicies(); Assert.assertEquals("should return active, published policies", Arrays.asList( new ControlPointPolicy("1", "archive", true, true), new ControlPointPolicy("2", "delete", true, true) ), result); }
@RequestMapping(method = RequestMethod.GET) public List<ControlPointPolicy> getPolicies() throws ControlPointApiException { checkEnabled(); return controlPointService.getPolicies().stream() .filter(policy -> policy.isActive() && policy.isPublished()) .collect(Collectors.toList()); }
ControlPointPolicyController { @RequestMapping(method = RequestMethod.GET) public List<ControlPointPolicy> getPolicies() throws ControlPointApiException { checkEnabled(); return controlPointService.getPolicies().stream() .filter(policy -> policy.isActive() && policy.isPublished()) .collect(Collectors.toList()); } }
ControlPointPolicyController { @RequestMapping(method = RequestMethod.GET) public List<ControlPointPolicy> getPolicies() throws ControlPointApiException { checkEnabled(); return controlPointService.getPolicies().stream() .filter(policy -> policy.isActive() && policy.isPublished()) .collect(Collectors.toList()); } @Autowired  ControlPointPolicyController(
        final ControlPointService controlPointService,
        final SavedSearchService<SavedSnapshot, SavedSnapshot.Builder> savedSnapshotService,
        final HavenSearchAciParameterHandler aciParameterHandler
    ); }
ControlPointPolicyController { @RequestMapping(method = RequestMethod.GET) public List<ControlPointPolicy> getPolicies() throws ControlPointApiException { checkEnabled(); return controlPointService.getPolicies().stream() .filter(policy -> policy.isActive() && policy.isPublished()) .collect(Collectors.toList()); } @Autowired  ControlPointPolicyController(
        final ControlPointService controlPointService,
        final SavedSearchService<SavedSnapshot, SavedSnapshot.Builder> savedSnapshotService,
        final HavenSearchAciParameterHandler aciParameterHandler
    ); @RequestMapping(method = RequestMethod.GET) List<ControlPointPolicy> getPolicies(); @RequestMapping(value = APPLY_PATH, method = RequestMethod.POST) void applyPolicy(
        @RequestParam(value = POLICY_PARAM) final String policy,
        @RequestParam(value = SAVED_SNAPSHOT_ID_PARAM, required = false) final Long snapshotId,
        @RequestBody(required = false) final SavedQuery query
    ); }
ControlPointPolicyController { @RequestMapping(method = RequestMethod.GET) public List<ControlPointPolicy> getPolicies() throws ControlPointApiException { checkEnabled(); return controlPointService.getPolicies().stream() .filter(policy -> policy.isActive() && policy.isPublished()) .collect(Collectors.toList()); } @Autowired  ControlPointPolicyController(
        final ControlPointService controlPointService,
        final SavedSearchService<SavedSnapshot, SavedSnapshot.Builder> savedSnapshotService,
        final HavenSearchAciParameterHandler aciParameterHandler
    ); @RequestMapping(method = RequestMethod.GET) List<ControlPointPolicy> getPolicies(); @RequestMapping(value = APPLY_PATH, method = RequestMethod.POST) void applyPolicy(
        @RequestParam(value = POLICY_PARAM) final String policy,
        @RequestParam(value = SAVED_SNAPSHOT_ID_PARAM, required = false) final Long snapshotId,
        @RequestBody(required = false) final SavedQuery query
    );  }