### Question:
ConstraintValidatorImpl implements ConstraintValidator { @Override public AgainstResourceType verifyActions(final Set<String> actions) { return new AgainstResourceType() { @Override public ConstraintResult against(ResourceType resourceType) { return verifyActions(actions, resourceType); } }; }  @Override ResourceMatchUsing verifyResources(final Set<String> resources); @Override AgainstResourceType verifyActions(final Set<String> actions);  }### Answer:
@Test public void exactActionsPass() { ResourceType resourceType = ResourceType .builder() .setName("test") .setUUID("abc") .addAction("GET", true) .addAction("POST", true) .build(); Set<String> actions = CollectionUtils .asSet("GET", "POST"); boolean successful = validator .verifyActions(actions) .against(resourceType) .isSuccessful(); assertThat(successful).isTrue(); }
@Test public void subsetActionsPass() { ResourceType resourceType = ResourceType .builder() .setName("test") .setUUID("abc") .addAction("GET", true) .addAction("POST", true) .addAction("DELETE", true) .addAction("PATCH", true) .build(); Set<String> actions = CollectionUtils .asSet("GET", "POST"); boolean successful = validator .verifyActions(actions) .against(resourceType) .isSuccessful(); assertThat(successful).isTrue(); }
@Test public void additionalActionsFail() { ResourceType resourceType = ResourceType .builder() .setName("test") .setUUID("abc") .addAction("GET", true) .addAction("POST", true) .build(); Set<String> actions = CollectionUtils .asSet("GET", "POST", "DELETE"); boolean successful = validator .verifyActions(actions) .against(resourceType) .isSuccessful(); assertThat(successful).isFalse(); }
@Test(expectedExceptions = ConstraintFailureException.class, expectedExceptionsMessageRegExp = "Invalid value DELETE for property actionValues") public void throwsExceptionWhenActionsFail() throws ConstraintFailureException { ResourceType resourceType = ResourceType .builder() .setName("test") .setUUID("abc") .addAction("GET", true) .addAction("POST", true) .build(); Set<String> actions = CollectionUtils .asSet("GET", "POST", "DELETE"); validator .verifyActions(actions) .against(resourceType) .throwExceptionIfFailure(); }