示例#1
0
  //  @Test
  public void create() throws Exception {
    List<AddJob> addJobs = new ArrayList<AddJob>();

    AddJob addJob = AddJobFactory.createAddJob("Brakes", "Audi", 5000, 2);

    addJobs.add(addJob);

    this.repository.save(addJob);
    id = addJob.getId();
    Assert.assertNotNull(addJob.getId());
  }
示例#2
0
  //  @Test(dependsOnMethods = "read")
  public void update() throws Exception {
    AddJob addJob = repository.findOne(id);

    AddJob newAddJob =
        new AddJob.Builder(addJob.getJobName()).copy(addJob).vehicle("Vw").price(1500).build();

    repository.save(newAddJob);

    AddJob updateJOb = repository.findOne(id);

    Assert.assertEquals("Audi", addJob.getVehicle());
    Assert.assertEquals("Vw", newAddJob.getVehicle());
  }
示例#3
0
  @RequestMapping(value = "/job/", method = RequestMethod.GET)
  public List<AddJobResource> getAddJobs() {
    List<AddJobResource> hateos = new ArrayList<AddJobResource>();

    List<AddJob> addJobs = service.findAll();
    AddJobResource res;
    Link jobs;
    for (AddJob addJob : addJobs) {
      res =
          new AddJobResource.Builder(addJob.getJobName())
              .resid(addJob.getId())
              .vehicle(addJob.getVehicle())
              .price(addJob.getPrice())
              .jobDuration(addJob.getJobDuration())
              .build();

      /*jobs = new Link ("http://localhost:8080/addJob/"+res.getResid().toString())
               .withRel("job");
      */

      jobs =
          (new

              // create a link to this method on
              Link(linkTo(methodOn(AddJobHome.class).getAddJobs()).slash(res.getResid()).toString())
              .withSelfRel());
      res.add(jobs);
      hateos.add(res);
    }

    return hateos;
  }