RESTMockServer { public static MatchableCall whenHEAD(Matcher<RecordedRequest> requestMatcher) { return RESTMockServer.whenRequested(allOf(isHEAD(), requestMatcher)); } private  RESTMockServer(); static SSLSocketFactory getSSLSocketFactory(); static X509TrustManager getTrustManager(); static RESTMockLogger getLogger(); synchronized static void init(RESTMockFileParser restMockFileParser, RESTMockLogger logger); synchronized static void init(RESTMockFileParser restMockFileParser, RESTMockLogger logger, RESTMockOptions restMockOptions); static void enableLogging(RESTMockLogger logger); static void disableLogging(); @Deprecated static void removeAllMatchableCalls(); static void reset(); static boolean removeMatchableCall(MatchableCall call); static void replaceMatchableCall(MatchableCall call, MatchableCall replacement); static String getUrl(); static void addMatchableCall(final MatchableCall call); static MatchableCall whenGET(Matcher<RecordedRequest> requestMatcher); static MatchableCall whenPOST(Matcher<RecordedRequest> requestMatcher); static MatchableCall whenPUT(Matcher<RecordedRequest> requestMatcher); static MatchableCall whenPATCH(Matcher<RecordedRequest> requestMatcher); static MatchableCall whenDELETE(Matcher<RecordedRequest> requestMatcher); static MatchableCall whenHEAD(Matcher<RecordedRequest> requestMatcher); static MatchableCall whenRequested(Matcher<RecordedRequest> requestMatcher); static void shutdown(); static final String RESPONSE_NOT_MOCKED; static final String MORE_THAN_ONE_RESPONSE_ERROR; }
@Test public void testWhenHEAD() throws Exception { String path = "/sample"; MatchableCall matchableCall = RESTMockServer.whenHEAD(pathEndsWith(path)); assertNotNull(matchableCall); assertEquals(0, matchableCall.getNumberOfAnswers()); verify(RESTMockServer.dispatcher, never()).addMatchableCall(matchableCall); TestUtils.assertNotMocked(TestUtils.get(path)); matchableCall.thenReturnEmpty(200); TestUtils.assertNotMocked(TestUtils.get(path)); TestUtils.assertNotMocked(TestUtils.post(path)); TestUtils.assertResponseCodeIs(TestUtils.head(path), 200); TestUtils.assertNotMocked(TestUtils.put(path)); TestUtils.assertNotMocked(TestUtils.delete(path)); }