@Test public void shouldSetMethodNotAllowedStatus() throws Exception { status.methodNotAllowed(EnumSet.of(HttpMethod.GET, HttpMethod.POST)); verify(response).sendError(405); verify(response).addHeader("Allow", "GET, POST"); }
private boolean analyzeImplementation(ResourceMethod method, ParameterizedType parameterized) { Type parameterType = parameterized.getActualTypeArguments()[0]; Class<?> found = (Class<?>) parameterType; T resource = retrieveResource(found); if(resource==null) { status.notFound(); return false; } if(allows(resource, method.getMethod())) { return true; } status.methodNotAllowed(allowedMethods()); return false; }
@Test public void onStatusResultShouldThrowExceptionsOnMethodNotAllowed() throws Exception { exception.expect(ValidationException.class); Status status = mock(Status.class); when(result.use(Status.class)).thenReturn(status); factory.instanceFor(Status.class, errors).methodNotAllowed(EnumSet.allOf(HttpMethod.class)); }