package com.tfl.api.test;

import com.frameworkium.core.api.tests.BaseAPITest;
import com.tfl.api.dto.bikepoints.BikePoints;
import com.tfl.api.dto.common.Place;
import com.tfl.api.service.bikepoints.BikePointService;
import com.tfl.api.service.bikepoints.BikePointsParamsBuilder;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import ru.yandex.qatools.allure.annotations.TestCaseId;

import java.util.List;
import java.util.Map;

import static com.google.common.truth.Truth.assertThat;

@Test
public class BikePointsTest extends BaseAPITest {

    private BikePoints bikePoints;

    @BeforeClass
    public void setUp() {
        bikePoints = new BikePointService().getBikePoints();
    }

    @TestCaseId("BP-1")
    public void all_bikes_contains_a_known_place_and_there_are_a_lot_of_them() {

        List<String> allNames = bikePoints.getAllNames();

        assertThat(allNames).contains("Evesham Street, Avondale");
        assertThat(allNames.size()).isAtLeast(700);
    }

    @TestCaseId("BP-2")
    public void given_lat_long_of_point_point_appears_in_lat_long_search() {

        // Get random bike point
        Place randomBP = bikePoints.getRandomBikePoint();

        // Search for lat long of said bike point with 200m radius
        Map<String, String> params =
                new BikePointsParamsBuilder()
                        .latitude(randomBP.lat)
                        .longditude(randomBP.lon)
                        .radiusInMeters(200)
                        .build();

        BikePoints searchResults = new BikePointService().searchBikePoints(params);

        // Then said bike point is part of result set
        assertThat(searchResults.getAllNames())
                .contains(randomBP.commonName);
    }
}

@@ -643,13 +643,37 @@
 oid 
-setUp
+cache_get_bike_points_results
 () %7B
@@ -749,81 +749,20 @@
     
-@TestCaseId(%22BP-1%22)%0A    public void all_bikes_contains_a_known_place_and_
+public void 
 ther
@@ -780,12 +780,19 @@
 _of_
-them
+bike_points
 () %7B
@@ -805,208 +805,256 @@
     
-List%3CString%3E allNames = bikePoints.getAllNames();%0A%0A        assertThat(allNames).contains(%22Evesham Street, Avondale%22);%0A        assertThat(allNames.size()).isAtLeast(700);%0A    %7D%0A%0A    @TestCaseId(%22BP-2%22)
+assertThat(bikePoints.getAllNames().size())%0A                .isAtLeast(700);%0A    %7D%0A%0A    public void known_name_exists_in_all_bike_points() %7B%0A%0A        assertThat(bikePoints.getAllNames())%0A                .contains(%22Evesham Street, Avondale%22);%0A    %7D%0A
 %0A   

Improve bike points test