RestMockService extends AbstractMockService<RestMockAction, RESTMockServiceConfig> { public RestMockAction addNewMockAction(RestRequest restRequest) { RestMockAction mockAction = addEmptyMockAction(restRequest.getMethod(), RestUtils.getExpandedPath(restRequest.getPath(), restRequest.getParams(), restRequest)); mockAction.setResource(restRequest.getResource()); return mockAction; } RestMockService(Project project, RESTMockServiceConfig config); String getStringID(); @Override String getIconName(); @Override MockDispatcher createDispatcher(WsdlMockRunContext mockContext); @Override List<? extends ModelItem> getChildren(); RestMockAction addNewMockAction(RestRequest restRequest); RestMockAction addEmptyMockAction(HttpMethod method, String path); MockOperation findOrCreateNewOperation(RestRequest restRequest); boolean canIAddAMockOperation(RestMockAction mockOperation); @Override MockOperation addNewMockOperation(Operation operation); List<MockOperation> addNewMockOperationsFromResource(RestResource restResource); @Override String getHelpUrl(); final static String ICON_NAME; static final String STRING_ID; }
@Test public void shouldAddNewMockAction() throws SoapUIException { restMockService.addNewMockAction(restRequest); RestMockAction restMockAction = restMockService.getMockOperationAt(0); assertEquals(PATH, restMockAction.getResourcePath()); assertEquals(GET, restMockAction.getMethod()); }
@Test public void shouldAddNewMockActionWithEmptyPath() throws SoapUIException { restRequest.setPath("/"); restMockService.addNewMockAction(restRequest); RestMockAction restMockAction = restMockService.getMockOperationAt(0); assertEquals("/", restMockAction.getResourcePath()); assertEquals(GET, restMockAction.getMethod()); }