TrackLabels { @Nullable static TrackLabels from(@NonNull List<MLocation> points) { try { final TrackLabels labels = findExitLand(points); if (labels != null) { labels.deploy = findDeploy(points, labels.exit, labels.land); } return labels; } catch (Exception e) { Exceptions.report(e); return null; } } private  TrackLabels(int exit, int deploy, int land);   }
@Test public void empty() { final List<MLocation> points = new ArrayList<>(); final TrackLabels labels = TrackLabels.from(points); assertNull(labels); }
@Test public void singleton() { final List<MLocation> points = Collections.singletonList(point(0, FlightMode.MODE_WINGSUIT)); final TrackLabels labels = TrackLabels.from(points); assertNull(labels); }
@Test public void labels() { final List<MLocation> points = Arrays.asList( point(0, FlightMode.MODE_GROUND), point(1000, FlightMode.MODE_GROUND), point(2000, FlightMode.MODE_WINGSUIT), point(3000, FlightMode.MODE_WINGSUIT), point(4000, FlightMode.MODE_WINGSUIT), point(5000, FlightMode.MODE_CANOPY), point(6000, FlightMode.MODE_CANOPY), point(7000, FlightMode.MODE_GROUND) ); final TrackLabels labels = TrackLabels.from(points); assertNotNull(labels); assertEquals(2, labels.exit); assertEquals(4, labels.deploy); assertEquals(6, labels.land); }
@Test public void canopyOnly() { final List<MLocation> points = Arrays.asList( point(7000, FlightMode.MODE_CANOPY), point(8000, FlightMode.MODE_CANOPY), point(9000, FlightMode.MODE_CANOPY) ); final TrackLabels labels = TrackLabels.from(points); assertNotNull(labels); assertEquals(0, labels.exit); assertEquals(0, labels.deploy); assertEquals(2, labels.land); }