@GET
 @Path("/getvehiclelocation/{vehicle}")
 @Produces(MediaType.APPLICATION_JSON)
 public Response getVehicleLocation(@PathParam("vehicle") String vehicle) {
   Location result = service.getVehicleLocation(vehicle);
   return Response.status(201).entity(result).build();
 }
 @GET
 @Path("/getvehicles/{tile}")
 @Produces(MediaType.APPLICATION_JSON)
 public Response getVehiclesByTile(@PathParam("tile") String tile) {
   List<Vehicle> result = service.getVehiclesByTile(tile);
   return Response.status(201).entity(result).build();
 }
 @GET
 @Path("/getmovements/{vehicle}/{date}")
 @Produces(MediaType.APPLICATION_JSON)
 public Response getMovements(
     @PathParam("vehicle") String vehicle, @PathParam("date") String dateString) {
   List<Vehicle> result = service.getVehicleMovements(vehicle, dateString);
   return Response.status(201).entity(result).build();
 }
 @GET
 @Path("/addVehicleEvent/{vehicle}/{name}/{value}")
 @Produces("text/html")
 public Response addVehicleEvent(
     @PathParam("vehicle") String vehicle,
     @PathParam("name") String name,
     @PathParam("value") String value) {
   service.addVehicleEvent(vehicle, name, value);
   return Response.ok("success").build();
 }
 @GET
 @Path("/search/{lat}/{lon}/{elevation}/{distance}")
 @Produces(MediaType.APPLICATION_JSON)
 public Response searchForVehicles(
     @PathParam("lat") double lat,
     @PathParam("lon") double lon,
     @PathParam("elevation") double elevation,
     @PathParam("distance") int distance) {
   List<Vehicle> result =
       service.searchVehiclesByLonLatAndDistance(
           distance, new Location(new LatLong(lat, lon), elevation));
   return Response.status(201).entity(result).build();
 }
  @Test
  public void editVehicleFromGarage() throws Exception {
    VehicleRequest vehicleRequest = new VehicleRequest();
    VehicleResponse vehicleResponse = new VehicleResponse();
    when(vehicleService.editVehicle(vehicleRequest, "gId", "vId")).thenReturn(vehicleResponse);

    mockMvc
        .perform(
            put("/garages/{garageId}/vehicles/{vehicleId}", "gId", "vId")
                .accept(MediaType.APPLICATION_JSON)
                .contentType(MediaType.APPLICATION_JSON)
                .content("{}"))
        .andExpect(status().isAccepted());

    verify(vehicleService, times(1))
        .editVehicle(any(VehicleRequest.class), anyString(), anyString());
  }
 @GET
 @Path("/updateVehicleLocation/{vehicle}/{lon}/{lat}/{elevation}/{speed}/{acceleration}")
 @Produces("text/html")
 public Response updateVehicleLocation(
     @PathParam("vehicle") String vehicle,
     @PathParam("lon") String lon,
     @PathParam("lat") String lat,
     @PathParam("elevation") String elevation,
     @PathParam("speed") String speed,
     @PathParam("acceleration") String acceleration) {
   service.updateVehicleLocation(
       vehicle,
       new Location(
           new LatLong(Double.parseDouble(lat), Double.parseDouble(lon)),
           Double.parseDouble(elevation)),
       Double.parseDouble(speed),
       Double.parseDouble(acceleration));
   return Response.ok("success").build();
 }
  private void generateVehicles() {
    // Cahs
    VehicleMake vehicleMake1 = new VehicleMake("Faraday");
    vehicleMakeService.saveVehicleMake(vehicleMake1);

    VehicleModel modelB = new VehicleModel("Model B");
    modelB.setVehicleMake(vehicleMake1);
    vehicleModelService.saveVehicleModel(modelB);

    VehicleModel modelU = new VehicleModel("Model U");
    modelU.setVehicleMake(vehicleMake1);
    vehicleModelService.saveVehicleModel(modelU);

    VehicleModel modelTT = new VehicleModel("Model TT");
    modelTT.setVehicleMake(vehicleMake1);
    vehicleModelService.saveVehicleModel(modelTT);

    VehicleMake vehicleMake2 = new VehicleMake("Choovy");
    vehicleMakeService.saveVehicleMake(vehicleMake2);

    VehicleModel canyonero = new VehicleModel("Canyonero");
    canyonero.setVehicleMake(vehicleMake2);
    vehicleModelService.saveVehicleModel(canyonero);

    VehicleModel suburbanite = new VehicleModel("Suburbanite");
    suburbanite.setVehicleMake(vehicleMake2);
    vehicleModelService.saveVehicleModel(suburbanite);

    VehicleModel theCamino = new VehicleModel("The Camino");
    theCamino.setVehicleMake(vehicleMake2);
    vehicleModelService.saveVehicleModel(theCamino);

    VehicleMake vehicleMake3 = new VehicleMake("Ferd");
    vehicleMakeService.saveVehicleMake(vehicleMake3);

    VehicleModel f150 = new VehicleModel("Eff Won Fiddy");
    f150.setVehicleMake(vehicleMake3);
    vehicleModelService.saveVehicleModel(f150);

    VehicleModel f350 = new VehicleModel("Eff Tree Fiddy");
    f350.setVehicleMake(vehicleMake3);
    vehicleModelService.saveVehicleModel(f350);

    VehicleModel thunderCougarFalconBird = new VehicleModel("ThunderCougarFalconBird");
    thunderCougarFalconBird.setVehicleMake(vehicleMake3);
    vehicleModelService.saveVehicleModel(thunderCougarFalconBird);

    Vehicle v1 = new Vehicle();
    v1.setYear(1999);
    v1.setPlate("ABC123");
    v1.setVin("11223344556677889900");
    v1.setColor("Cornflower");
    v1.setVehicleModel(modelB);
    vehicleService.saveVehicle(v1);

    Vehicle v2 = new Vehicle();
    v2.setYear(2012);
    v2.setPlate("DEF456");
    v2.setVin("1223344556677889900");
    v2.setColor("Viridion");
    v2.setVehicleModel(theCamino);
    vehicleService.saveVehicle(v2);

    Vehicle v3 = new Vehicle();
    v3.setYear(2015);
    v3.setPlate("GHI789");
    v3.setVin("321321321321321321");
    v3.setColor("VantaBlack");
    v3.setVehicleModel(canyonero);
    vehicleService.saveVehicle(v3);

    Vehicle v4 = new Vehicle();
    v4.setYear(2016);
    v4.setPlate("JKL012");
    v4.setVin("42424242424242424242");
    v4.setColor("Emerald");
    v4.setVehicleModel(f350);
    vehicleService.saveVehicle(v4);

    Vehicle v5 = new Vehicle();
    v5.setYear(2015);
    v5.setPlate("AAA111");
    v5.setVin("YEAHIMTOTALLYAVIN");
    v5.setColor("Garnet");
    v5.setVehicleModel(thunderCougarFalconBird);
    vehicleService.saveVehicle(v5);
  }