ManeuverResources { public int getManeuverIconId(final int index) { final Maneuver maneuver = getManeuverAt(index); if (maneuver == null) { return 0; } if (maneuver.getAction() == com.here.android.mpa.routing.Maneuver.Action.FERRY && isCarShuttleTrainManeuver(maneuver)) { return R.drawable.ic_maneuver_icon_motorail; } return getManeuverIconId(maneuver.getIcon()); } @SuppressWarnings("PMD.NcssCount") // There is no purpose to break this constuctor into smaller functions. /** * Constructs a new instance using a list of maneuvers. */  ManeuverResources(final Context context, final List<Maneuver> maneuverList); int getStartIconId(); int getDestinationIconId(); int getManeuverIconId(final int index); String getManeuverInstruction(final int index); int getDistanceFromNext(final int index); String getRoadToDisplay(final int index); String getExitDirections(final Maneuver maneuver); String getString(final Integer id); String getArrivedAtDestinationInstruction();  }
@Test public void testGetManeuverIconIdReturnsCarShuttleTrainIconForCarShuttleFerryManeuvers() { Maneuver maneuver = mock(Maneuver.class); when(maneuver.getAction()).thenReturn(Action.FERRY); when(maneuver.getIcon()).thenReturn(com.here.android.mpa.routing.Maneuver.Icon.FERRY); RoadElement carShuttleRoadElement = mock(RoadElement.class); when(carShuttleRoadElement.getAttributes()).thenReturn(EnumSet.of(RoadElement.Attribute.CAR_SHUTTLE_TRAIN, RoadElement.Attribute .FERRY)); when(maneuver.getRoadElements()).thenReturn(Collections.singletonList(carShuttleRoadElement)); mManeuverResources = new ManeuverResources(getApplicationContext(), new ArrayList<>(Collections.singletonList(maneuver))); assertThat(mManeuverResources.getManeuverIconId(0), equalTo(R.drawable.ic_maneuver_icon_motorail)); }
@Test public void testGetManeuverIconIdReturnsFerryIconForBoatFerryManeuvers() { Maneuver maneuver = mock(Maneuver.class); when(maneuver.getAction()).thenReturn(Action.FERRY); when(maneuver.getIcon()).thenReturn(com.here.android.mpa.routing.Maneuver.Icon.FERRY); RoadElement carShuttleRoadElement = mock(RoadElement.class); when(carShuttleRoadElement.getAttributes()).thenReturn(EnumSet.of(RoadElement.Attribute.FERRY)); when(maneuver.getRoadElements()).thenReturn(Collections.singletonList(carShuttleRoadElement)); mManeuverResources = new ManeuverResources(getApplicationContext(), new ArrayList<>(Collections.singletonList(maneuver))); assertThat(mManeuverResources.getManeuverIconId(0), equalTo(R.drawable.ic_maneuver_icon_45)); }