/** * 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<UpdateRestResourcesForwardedEndpointOutput> process(final ServiceTask<UpdateRestResourcesForwardedEndpointInput> serviceTask) { final UpdateRestResourcesForwardedEndpointInput input = serviceTask.getInput(); final List<RestResource> resources = this.resourceRepository.findWithApplicationId(input.getRestApplicationId()); resources.stream() .map(RestResource::getId) .map(this.methodRepository::findWithResourceId) .flatMap(List::stream) .forEach(restMethod -> { restMethod.setForwardedEndpoint(input.getForwardedEndpoint()); this.methodRepository.update(restMethod.getId(), restMethod); }); return createServiceResult(UpdateRestResourcesForwardedEndpointOutput.builder().build()); } }
public static RestMethod generateRestMethod(){ final RestMethod restMethod = new RestMethod(); restMethod.setId("REST METHOD"); restMethod.setName("REST method name"); restMethod.setForwardedEndpoint("Forward endpoint"); restMethod.setDefaultBody("Default body"); restMethod.setCurrentResponseSequenceIndex(1); restMethod.setStatus(RestMethodStatus.MOCKED); restMethod.setHttpMethod(HttpMethod.GET); restMethod.setMockResponses(new ArrayList<RestMockResponse>()); restMethod.setResponseStrategy(RestResponseStrategy.RANDOM); return restMethod; } }
/** * 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<UpdateRestMethodsForwardedEndpointOutput> process(final ServiceTask<UpdateRestMethodsForwardedEndpointInput> serviceTask) { final UpdateRestMethodsForwardedEndpointInput input = serviceTask.getInput(); for(RestMethod inputRestMethod : input.getRestMethods()){ final RestMethod restMethod = this.methodRepository.findOne(inputRestMethod.getId()); restMethod.setForwardedEndpoint(input.getForwardedEndpoint()); this.methodRepository.update(restMethod.getId(), restMethod); } return createServiceResult(UpdateRestMethodsForwardedEndpointOutput.builder().build()); } }
restMethod.setStatus(RestMethodStatus.MOCKED); restMethod.setResponseStrategy(RestResponseStrategy.SEQUENCE); restMethod.setForwardedEndpoint(forwardAddress);
/** * 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<UpdateRestApplicationsForwardedEndpointOutput> process(final ServiceTask<UpdateRestApplicationsForwardedEndpointInput> serviceTask) { final UpdateRestApplicationsForwardedEndpointInput input = serviceTask.getInput(); for(RestApplication restApplication : input.getRestApplications()){ List<RestResource> resources = this.resourceRepository.findWithApplicationId(restApplication.getId()); for(RestResource restResource : resources){ List<RestMethod> methods = this.methodRepository.findWithResourceId(restResource.getId()); for(RestMethod restMethod : methods){ restMethod.setForwardedEndpoint(input.getForwardedEndpoint()); this.methodRepository.update(restMethod.getId(), restMethod); } } } return createServiceResult(UpdateRestApplicationsForwardedEndpointOutput.builder().build()); } }
restMethod.setForwardedEndpoint(FORWARD_ENDPOINT); restMethod.setHttpMethod(HttpMethod.GET); restMethod.setId(METHOD_ID);
/** * 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()); } }
restMethod.setId(methodV1.getId()); restMethod.setHttpMethod(methodV1.getHttpMethod()); restMethod.setForwardedEndpoint(methodV1.getForwardedEndpoint()); restMethod.setDefaultBody(methodV1.getDefaultBody()); restMethod.setCurrentResponseSequenceIndex(methodV1.getCurrentResponseSequenceIndex());
restMethod.setForwardedEndpoint(FORWARD_ENDPOINT); restMethod.setHttpMethod(HttpMethod.GET); restMethod.setId(METHOD_ID);