@Test public void resolveRightVerb() throws Exception { assertThat(resolverUnderTest.resolve(Fixture.class.getDeclaredMethod("doGet", HttpServletRequest.class, HttpServletResponse.class))).isEqualTo(Optional.of(CrudAction.READ)); assertThat(resolverUnderTest.resolve(Fixture.class.getDeclaredMethod("doHead", HttpServletRequest.class, HttpServletResponse.class))).isEqualTo(Optional.of(CrudAction.READ)); assertThat(resolverUnderTest.resolve(Fixture.class.getDeclaredMethod("doPost", HttpServletRequest.class, HttpServletResponse.class))).isEqualTo(Optional.of(CrudAction.CREATE)); assertThat(resolverUnderTest.resolve(Fixture.class.getDeclaredMethod("doPut", HttpServletRequest.class, HttpServletResponse.class))).isEqualTo(Optional.of(CrudAction.UPDATE)); assertThat(resolverUnderTest.resolve(Fixture.class.getDeclaredMethod("doDelete", HttpServletRequest.class, HttpServletResponse.class))).isEqualTo(Optional.of(CrudAction.DELETE)); assertThat(resolverUnderTest.resolve(Fixture.class.getDeclaredMethod("doOptions", HttpServletRequest.class, HttpServletResponse.class))).isEqualTo(Optional.of(CrudAction.READ)); assertThat(resolverUnderTest.resolve(Fixture.class.getDeclaredMethod("doTrace", HttpServletRequest.class, HttpServletResponse.class))).isEqualTo(Optional.of(CrudAction.READ)); assertThat(resolverUnderTest.resolve(Fixture.class.getMethod("doGet"))).isNotPresent(); }
@Override public Optional<CrudAction> resolve(Method method) { if (HttpServlet.class.isAssignableFrom(method.getDeclaringClass()) && Arrays.equals(method.getParameterTypes(), PARAMETER_TYPES)) { switch (method.getName()) { case "doDelete": return Optional.of(CrudAction.DELETE); case "doGet": return Optional.of(CrudAction.READ); case "doHead": return Optional.of(CrudAction.READ); case "doOptions": return Optional.of(CrudAction.READ); case "doPost": return Optional.of(CrudAction.CREATE); case "doPut": return Optional.of(CrudAction.UPDATE); case "doTrace": return Optional.of(CrudAction.READ); default: return Optional.empty(); } } else { return Optional.empty(); } }
ServletCrudActionResolver implements CrudActionResolver { @Override public Optional<CrudAction> resolve(Method method) { if (HttpServlet.class.isAssignableFrom(method.getDeclaringClass()) && Arrays.equals(method.getParameterTypes(), PARAMETER_TYPES)) { switch (method.getName()) { case "doDelete": return Optional.of(CrudAction.DELETE); case "doGet": return Optional.of(CrudAction.READ); case "doHead": return Optional.of(CrudAction.READ); case "doOptions": return Optional.of(CrudAction.READ); case "doPost": return Optional.of(CrudAction.CREATE); case "doPut": return Optional.of(CrudAction.UPDATE); case "doTrace": return Optional.of(CrudAction.READ); default: return Optional.empty(); } } else { return Optional.empty(); } } }
ServletCrudActionResolver implements CrudActionResolver { @Override public Optional<CrudAction> resolve(Method method) { if (HttpServlet.class.isAssignableFrom(method.getDeclaringClass()) && Arrays.equals(method.getParameterTypes(), PARAMETER_TYPES)) { switch (method.getName()) { case "doDelete": return Optional.of(CrudAction.DELETE); case "doGet": return Optional.of(CrudAction.READ); case "doHead": return Optional.of(CrudAction.READ); case "doOptions": return Optional.of(CrudAction.READ); case "doPost": return Optional.of(CrudAction.CREATE); case "doPut": return Optional.of(CrudAction.UPDATE); case "doTrace": return Optional.of(CrudAction.READ); default: return Optional.empty(); } } else { return Optional.empty(); } }  }
ServletCrudActionResolver implements CrudActionResolver { @Override public Optional<CrudAction> resolve(Method method) { if (HttpServlet.class.isAssignableFrom(method.getDeclaringClass()) && Arrays.equals(method.getParameterTypes(), PARAMETER_TYPES)) { switch (method.getName()) { case "doDelete": return Optional.of(CrudAction.DELETE); case "doGet": return Optional.of(CrudAction.READ); case "doHead": return Optional.of(CrudAction.READ); case "doOptions": return Optional.of(CrudAction.READ); case "doPost": return Optional.of(CrudAction.CREATE); case "doPut": return Optional.of(CrudAction.UPDATE); case "doTrace": return Optional.of(CrudAction.READ); default: return Optional.empty(); } } else { return Optional.empty(); } }  @Override Optional<CrudAction> resolve(Method method); }
ServletCrudActionResolver implements CrudActionResolver { @Override public Optional<CrudAction> resolve(Method method) { if (HttpServlet.class.isAssignableFrom(method.getDeclaringClass()) && Arrays.equals(method.getParameterTypes(), PARAMETER_TYPES)) { switch (method.getName()) { case "doDelete": return Optional.of(CrudAction.DELETE); case "doGet": return Optional.of(CrudAction.READ); case "doHead": return Optional.of(CrudAction.READ); case "doOptions": return Optional.of(CrudAction.READ); case "doPost": return Optional.of(CrudAction.CREATE); case "doPut": return Optional.of(CrudAction.UPDATE); case "doTrace": return Optional.of(CrudAction.READ); default: return Optional.empty(); } } else { return Optional.empty(); } }  @Override Optional<CrudAction> resolve(Method method);  }