public static RestProject generateRestProject(){ 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>()); return project; }
private RestProject createRestProject(String name) { RestProject restProject = new RestProject(); restProject.setName(name); return restProject; } }
/** * Updates a project with new information * @param restProjectId The id of the project that will be updated * @param updatedProject The updated version of the project * @return The updated version project */ @Override protected RestProject update(final String restProjectId, final RestProject updatedProject){ Preconditions.checkNotNull(restProjectId, "Project id be null"); Preconditions.checkNotNull(updatedProject, "Project cannot be null"); Preconditions.checkArgument(!updatedProject.getName().isEmpty(), "Invalid project name. Project name cannot be empty"); final RestProject projectWithName = repository.findRestProjectWithName(updatedProject.getName()); Preconditions.checkArgument(projectWithName == null || projectWithName.getId().equals(restProjectId), "Project name is already taken"); final RestProject project = find(restProjectId); project.setName(updatedProject.getName()); project.setDescription(updatedProject.getDescription()); return super.save(project); }
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; }
project.setDescription(projectV1.getDescription()); project.setId(projectV1.getId()); project.setName(projectV1.getName());