@Test public void test_that_resolves_to_the_right_verb() throws Exception { assertThat(resolverUnderTest.resolve(Fixture.class.getMethod("delete"))).isPresent().contains( CrudAction.DELETE); assertThat(resolverUnderTest.resolve(Fixture.class.getMethod("get"))).isPresent().contains(CrudAction.READ); assertThat(resolverUnderTest.resolve(Fixture.class.getMethod("head"))).isPresent().contains(CrudAction.READ); assertThat(resolverUnderTest.resolve(Fixture.class.getMethod("options"))).isPresent().contains(CrudAction.READ); assertThat(resolverUnderTest.resolve(Fixture.class.getMethod("post"))).isPresent().contains(CrudAction.CREATE); assertThat(resolverUnderTest.resolve(Fixture.class.getMethod("put"))).isPresent().contains(CrudAction.UPDATE); assertThat(resolverUnderTest.resolve(Fixture.class.getMethod("none"))).isNotPresent(); assertThat(resolverUnderTest.resolve(Fixture.class.getMethod("random"))).isNotPresent(); }
@Override public Optional<CrudAction> resolve(Method method) { return Arrays.stream(method.getAnnotations()) .map(Annotation::annotationType) .map(x -> annotationMap.getOrDefault(x, null)) .filter(Objects::nonNull) .findFirst(); }
RestCrudActionResolver implements CrudActionResolver { @Override public Optional<CrudAction> resolve(Method method) { return Arrays.stream(method.getAnnotations()) .map(Annotation::annotationType) .map(x -> annotationMap.getOrDefault(x, null)) .filter(Objects::nonNull) .findFirst(); } }
RestCrudActionResolver implements CrudActionResolver { @Override public Optional<CrudAction> resolve(Method method) { return Arrays.stream(method.getAnnotations()) .map(Annotation::annotationType) .map(x -> annotationMap.getOrDefault(x, null)) .filter(Objects::nonNull) .findFirst(); } RestCrudActionResolver(); }
RestCrudActionResolver implements CrudActionResolver { @Override public Optional<CrudAction> resolve(Method method) { return Arrays.stream(method.getAnnotations()) .map(Annotation::annotationType) .map(x -> annotationMap.getOrDefault(x, null)) .filter(Objects::nonNull) .findFirst(); } RestCrudActionResolver(); @Override Optional<CrudAction> resolve(Method method); }
RestCrudActionResolver implements CrudActionResolver { @Override public Optional<CrudAction> resolve(Method method) { return Arrays.stream(method.getAnnotations()) .map(Annotation::annotationType) .map(x -> annotationMap.getOrDefault(x, null)) .filter(Objects::nonNull) .findFirst(); } RestCrudActionResolver(); @Override Optional<CrudAction> resolve(Method method);  }