RestMockService extends AbstractMockService<RestMockAction, RESTMockServiceConfig> { @Override public MockOperation addNewMockOperation(Operation operation) { return addNewMockOperationsFromResource((RestResource) operation).get(0); } 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 shouldAddOperationToMockServiceAction() throws SoapUIException { RestMethod restMethod = mock(RestMethod.class); when(restMethod.getRequestAt(0)).thenReturn(restRequest); when(restMethod.getMethod()).thenReturn(RestRequestInterface.HttpMethod.GET); RestResource restResource = mock(RestResource.class); when(restResource.getRestMethodCount()).thenReturn(1); when(restResource.getFullPath()).thenReturn("/full/path"); List<RestMethod> restMethodList = new ArrayList<RestMethod>(); restMethodList.add(restMethod); when(restResource.getRestMethodList()).thenReturn(restMethodList); restMockService.addNewMockOperation(restResource); RestMockAction mockOperation = restMockService.getMockOperationAt(0); assertThat(mockOperation.getMethod(), is(restRequest.getMethod())); assertTrue(mockOperation.getResourcePath().contains("/full/path")); }