vehicles-api/src/test/java/com/udacity/vehicles/api/CarControllerTest.java
/**
     * Tests if the read operation appropriately returns a list of vehicles.
     * @throws Exception if the read operation of the vehicle list fails
     */
Tests if the read operation appropriately returns a list of vehicles.
@throws Exception if the read operation of the vehicle list fails
Tests if the read operation appropriately returns a list of vehicles . @throws Exception if the read operation of the vehicle list fails
@Test
    public void listCars() throws Exception {
        /**
         * TODO: Add a test to check that the `get` method works by calling
         *   the whole list of vehicles. This should utilize the car from `getCar()`
         *   below (the vehicle will be the first in the list).
         */
        Car myCar = getCar();
        mvc.perform(get(new URI("/cars")))
                .andExpect(content().contentType("application/hal+json;charset=UTF-8"))
                .andExpect(status().isOk())
                .andExpect(jsonPath("$._embedded.carList[0].id").value("1"))
                .andExpect(jsonPath("$._embedded.carList[0].details.model").value(myCar.getDetails().getModel()))
                .andExpect(jsonPath("$._embedded.carList[0]._links.self.href").value("http://localhost/cars/1"))
                .andExpect(jsonPath("$._links.self.href").value("http://localhost/cars"));
    }
@ Test public void listCars ( ) throws Exception { /**
         * TODO: Add a test to check that the `get` method works by calling
         *   the whole list of vehicles. This should utilize the car from `getCar()`
         *   below (the vehicle will be the first in the list).
         */ Car myCar = getCar ( ) ; mvc . perform ( get ( new URI ( "/cars" ) ) ) . andExpect ( content ( ) . contentType ( "application/hal+json;charset=UTF-8" ) ) . andExpect ( status ( ) . isOk ( ) ) . andExpect ( jsonPath ( "$._embedded.carList[0].id" ) . value ( "1" ) ) . andExpect ( jsonPath ( "$._embedded.carList[0].details.model" ) . value ( myCar . getDetails ( ) . getModel ( ) ) ) . andExpect ( jsonPath ( "$._embedded.carList[0]._links.self.href" ) . value ( "http://localhost/cars/1" ) ) . andExpect ( jsonPath ( "$._links.self.href" ) . value ( "http://localhost/cars" ) ) ; }
Tests if the read operation appropriately returns a list of vehicles.
Tests if the read operation appropriately returns a list of vehicles .