if(restMethod.getSimulateNetworkDelay() && restMethod.getNetworkDelay() >= 0){ try {
/** * The process message is responsible for processing an incoming serviceTask and generate * a response based on the incoming serviceTask input * @param serviceTask The serviceTask that will be processed by the service * @return A result based on the processed incoming serviceTask * @see ServiceTask * @see ServiceResult */ @Override public ServiceResult<UpdateRestMethodOutput> process(final ServiceTask<UpdateRestMethodInput> serviceTask) { final UpdateRestMethodInput input = serviceTask.getInput(); final RestMethod updatedRestMethod = input.getRestMethod(); final RestMethod existing = this.methodRepository.findOne(input.getRestMethodId()); existing.setName(updatedRestMethod.getName()); existing.setHttpMethod(updatedRestMethod.getHttpMethod()); existing.setResponseStrategy(updatedRestMethod.getResponseStrategy()); existing.setStatus(updatedRestMethod.getStatus()); existing.setForwardedEndpoint(updatedRestMethod.getForwardedEndpoint()); existing.setNetworkDelay(updatedRestMethod.getNetworkDelay()); existing.setSimulateNetworkDelay(updatedRestMethod.getSimulateNetworkDelay()); existing.setDefaultMockResponseId(updatedRestMethod.getDefaultMockResponseId()); this.methodRepository.update(input.getRestMethodId(), existing); return createServiceResult(UpdateRestMethodOutput.builder() .restMethod(updatedRestMethod) .build()); } }
Assert.assertEquals(Integer.valueOf(0), getAllMockServicesMethod.getCurrentResponseSequenceIndex()); Assert.assertEquals(0L, getAllMockServicesMethod.getNetworkDelay()); Assert.assertFalse(getAllMockServicesMethod.getSimulateNetworkDelay()); Assert.assertNull(getAllMockServicesMethod.getDefaultBody()); Assert.assertNull(getAllMockServicesMethod.getId()); Assert.assertEquals(Integer.valueOf(0), createMockMethod.getCurrentResponseSequenceIndex()); Assert.assertEquals(0L, createMockMethod.getNetworkDelay()); Assert.assertFalse(createMockMethod.getSimulateNetworkDelay()); Assert.assertNull(createMockMethod.getDefaultBody()); Assert.assertNull(createMockMethod.getId()); Assert.assertEquals(Integer.valueOf(0), headMockMethod.getCurrentResponseSequenceIndex()); Assert.assertEquals(0L, headMockMethod.getNetworkDelay()); Assert.assertFalse(headMockMethod.getSimulateNetworkDelay()); Assert.assertNull(headMockMethod.getDefaultBody()); Assert.assertNull(headMockMethod.getId()); Assert.assertEquals(Integer.valueOf(0), optionsMockMethod.getCurrentResponseSequenceIndex()); Assert.assertEquals(0L, optionsMockMethod.getNetworkDelay()); Assert.assertFalse(optionsMockMethod.getSimulateNetworkDelay()); Assert.assertNull(optionsMockMethod.getDefaultBody()); Assert.assertNull(optionsMockMethod.getId()); Assert.assertEquals(Integer.valueOf(0), getMockByIdMethod.getCurrentResponseSequenceIndex()); Assert.assertEquals(0L, getMockByIdMethod.getNetworkDelay()); Assert.assertFalse(getMockByIdMethod.getSimulateNetworkDelay()); Assert.assertNull(getMockByIdMethod.getDefaultBody()); Assert.assertNull(getMockByIdMethod.getId());
Assert.assertEquals(RestResponseStrategy.RANDOM, restMethod.getResponseStrategy()); Assert.assertEquals(0, restMethod.getNetworkDelay()); Assert.assertFalse(restMethod.getSimulateNetworkDelay()); Assert.assertNull(restMethod.getId()); Assert.assertNull(restMethod.getResourceId());