@Override public ResponseBuilder response() { return new MockResponseBuilder(); } }
@BeforeMethod public void setupFixture() { MockResponseBuilder.setCurrentTime(currentTime); underTest = context.getBean(AvailabilityEnforcerRequestProcessor.class); responseHolder = context.getBean(MockResponseHolder.class); request = mock(Request.class); when(request.getBaseUrl()).thenReturn("http://acme.com"); when(request.getOriginalRelativeUri()).thenReturn("/contextPath"); }
/******************************************************************************************************************* * ******************************************************************************************************************/ @BeforeMethod public void setupFixture() throws Exception { MockResponseBuilder.setCurrentTime(currentTime); resourceFile = mock(ResourceFile.class); when(resourceFile.asBytes()).thenReturn("FILE CONTENT".getBytes()); when(resourceFile.getMimeType()).thenReturn("text/plain"); when(resourceFile.getLatestModificationTime()).thenReturn(resourceLatestModifiedTime); headers = new HashMap<>(); request = mock(Request.class); when(request.getHeader(anyString())).thenAnswer(new Answer<String>() { @Override @Nonnull public String answer (final @Nonnull InvocationOnMock invocation) throws NotFoundException { final String name = (String)invocation.getArguments()[0]; return NotFoundException.throwWhenNull(headers.get(name), "Not found " + name); } }); underTest = new MockResponseHolder(); }