use of cl.smartcities.isci.transportinspector.backend.BusStop in project androidApp by InspectorIncognito.
the class BusStopHelper method getBusStopById.
/**
* Open the database, does a query, close the database and returns the BusStop that matches the
* given id.
*
* @param pId code of the desired BusStop
* @return BusStop that matches the given id, or null if the BusStop does not exists in the
* database
*/
public BusStop getBusStopById(String pId) {
Log.d("pID", pId);
Cursor cursor = getBusStopCursorById(pId);
List<BusStop> busStopList = this.cursorToBusStopList(cursor);
this.close();
if (busStopList.size() > 0)
return busStopList.get(0);
else
return null;
}
use of cl.smartcities.isci.transportinspector.backend.BusStop in project androidApp by InspectorIncognito.
the class FavouritesManger method getFavouriteBusStops.
static List<BusStop> getFavouriteBusStops(Context context) {
FavoriteHelper helper = new FavoriteHelper(context);
BusStopHelper busStopHelper = new BusStopHelper(context);
List<String> busStops = helper.getFavoriteBusStops();
List<BusStop> favouriteBusStops = new ArrayList<>();
if (!busStops.isEmpty()) {
List<BusStop> favourites = busStopHelper.getAllBusStopsIn(busStops.toArray(new String[busStops.size()]));
favouriteBusStops.addAll(favourites);
}
return favouriteBusStops;
}
use of cl.smartcities.isci.transportinspector.backend.BusStop in project androidApp by InspectorIncognito.
the class DetectionServiceTest method testManualGetOutOfBus.
@Test
public void testManualGetOutOfBus() throws TimeoutException {
DetectionService spyService = spy(service);
BusStop mockBusStop = mock(BusStop.class);
when(mockBusStop.getIncomingBuses()).thenReturn(new ArrayList<Bus>());
Bus bus = new Bus("506", "GGWP00", "");
spyService.setCurrentState(new VehicleState(new IdleState(spyService), bus, mock(StateLocationSender.class)));
spyService.onBusDetected(bus);
assertTrue(spyService.isRunningInForeground());
spyService.outOfBus();
assertFalse(spyService.isRunningInForeground());
}
use of cl.smartcities.isci.transportinspector.backend.BusStop in project androidApp by InspectorIncognito.
the class DetectionServiceTest method testGetOutOfBus.
@Test
public void testGetOutOfBus() throws TimeoutException {
DetectionService spyService = spy(service);
BusStop mockBusStop = mock(BusStop.class);
when(mockBusStop.getIncomingBuses()).thenReturn(new ArrayList<Bus>());
Bus bus = new Bus("506", "GGWP00", "");
spyService.setCurrentState(new VehicleState(new IdleState(spyService), bus, mock(StateLocationSender.class)));
spyService.onBusDetected(bus);
assertTrue(spyService.isRunningInForeground());
spyService.onActivityChanged(new DetectedActivity(DetectedActivity.WALKING, 100));
spyService.onActivityChanged(new DetectedActivity(DetectedActivity.IN_VEHICLE, 100));
spyService.onActivityChanged(new DetectedActivity(DetectedActivity.WALKING, 100));
spyService.fakeOnTimePassed();
assertFalse(spyService.isRunningInForeground());
}
use of cl.smartcities.isci.transportinspector.backend.BusStop in project androidApp by InspectorIncognito.
the class DetectionServiceTest method testBusDetectedNotificationIsSent.
@Test
public void testBusDetectedNotificationIsSent() throws TimeoutException {
DetectionService spyService = spy(service);
BusStop mockBusStop = mock(BusStop.class);
when(mockBusStop.getIncomingBuses()).thenReturn(new ArrayList<Bus>());
// IdleState is set
spyService.setCurrentState(new IdleState(spyService));
// BusStop is selected
spyService.busStopSelected(mockBusStop);
// New IN_VEHICLE Detected Activity
spyService.onActivityChanged(new DetectedActivity(DetectedActivity.IN_VEHICLE, 100));
// TODO(aantoine): REDO this test
// verify(spyService).sendNotification(anyInt(), any(NotificationCompat.Builder.class));
}
Aggregations