public static RestProject generateFullRestProject(){ final RestProject project = new RestProject(); project.setId("REST PROJECT"); project.setName("Project name"); project.setDescription("Project description"); project.setCreated(new Date()); project.setUpdated(new Date()); project.setApplications(new ArrayList<RestApplication>()); for(int applicationIndex = 0; applicationIndex < 3; applicationIndex++){ final RestApplication restApplication = RestApplicationGenerator.generateRestApplication(); restApplication.setResources(new ArrayList<RestResource>()); project.getApplications().add(restApplication); for(int resourceIndex = 0; resourceIndex < 3; resourceIndex++){ final RestResource restResource = RestResourceGenerator.generateRestResource(); restResource.setMethods(new ArrayList<RestMethod>()); restApplication.getResources().add(restResource); for(int methodIndex = 0; methodIndex < 3; methodIndex++){ final RestMethod restMethod = RestMethodGenerator.generateRestMethod(); restMethod.setMockResponses(new ArrayList<RestMockResponse>()); restResource.getMethods().add(restMethod); for(int responseIndex = 0; responseIndex < 3; responseIndex++){ final RestMockResponse restMockResponse = RestMockResponseGenerator.generateRestMockResponse(); restMethod.getMockResponses().add(restMockResponse); } } } } return project; }
for(RestApplication application : project.getApplications()) { if(this.applicationRepository.exists(application.getId())){ throw new IllegalArgumentException("An application with the following key already exists: " + application.getId());
/** * 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<ReadRestProjectOutput> process(final ServiceTask<ReadRestProjectInput> serviceTask) { final ReadRestProjectInput input = serviceTask.getInput(); final RestProject restProject = find(input.getRestProjectId()); final List<RestApplication> applications = this.applicationRepository.findWithProjectId(input.getRestProjectId()); restProject.setApplications(applications); for(final RestApplication restApplication : restProject.getApplications()){ final Map<RestMethodStatus, Integer> soapOperationStatusCount = getRestMethodStatusCount(restApplication); restApplication.setStatusCount(soapOperationStatusCount); } return createServiceResult(ReadRestProjectOutput.builder() .restProject(restProject) .build()); } }
application.setName(applicationV1.getName()); application.setProjectId(project.getId()); project.getApplications().add(application);