@Test public void testGettingRouteOptionsWhenMainItemIsSelected() { final MockUtils.MockRouteOptionsBuilder builder = new MockUtils.MockRouteOptionsBuilder(); final RouteOptions mockRouteOptions = builder.withFullHazardousOptions() .build(); mTruckOptionsPanel.setRouteOptions(mockRouteOptions); doAnswer(new AnswerGetRouteOptions(RouteOptions.TruckRestrictionsMode.PENALIZE_VIOLATIONS)).when(mockRouteOptions) .setTruckRestrictionsMode(any(RouteOptions.TruckRestrictionsMode.class)); final List<OptionItem> items = mTruckOptionsPanel.getOptionItems(); BooleanOptionItem booleanOptionItem = (BooleanOptionItem) items.get(items.size() - 1); booleanOptionItem.setChecked(true); }
@SuppressWarnings({"PMD.CyclomaticComplexity"}) public void setRouteOptions(final RouteOptions routeOptions) { if (routeOptions == null) { throw new IllegalArgumentException(getContext().getString(R.string.msdkui_exception_route_options_null)); } mRouteOptions = routeOptions; for (final OptionItem item : mSubItem) { if (item.getItemId() == R.string.msdkui_height) { ((NumericOptionItem) item).setValue(mRouteOptions.getTruckHeight()); } else if (item.getItemId() == R.string.msdkui_length) { ((NumericOptionItem) item).setValue(mRouteOptions.getTruckLength()); } else if (item.getItemId() == R.string.msdkui_width) { ((NumericOptionItem) item).setValue(mRouteOptions.getTruckWidth()); } else if (item.getItemId() == R.string.msdkui_limited_weight) { ((NumericOptionItem) item).setValue(mRouteOptions.getTruckLimitedWeight()); } else if (item.getItemId() == R.string.msdkui_weight_per_axle) { ((NumericOptionItem) item).setValue(mRouteOptions.getTruckWeightPerAxle()); } else if (item.getItemId() == R.string.msdkui_number_of_trailers) { ((NumericOptionItem) item).setInputType(InputType.TYPE_CLASS_NUMBER) .setValue(mRouteOptions.getTruckTrailersCount()); } else if (item.getItemId() == R.string.msdkui_truck_type) { ((SingleChoiceOptionItem) item).selectLabel(getTruckTypeLabel(mRouteOptions.getTruckType())); } else if (item.getItemId() == R.string.msdkui_violate_truck_options) { setRestriction(item); } } }
TruckOptionsPanel extends OptionsPanel implements OptionItem.OnChangedListener { @SuppressWarnings({"PMD.CyclomaticComplexity"}) public void setRouteOptions(final RouteOptions routeOptions) { if (routeOptions == null) { throw new IllegalArgumentException(getContext().getString(R.string.msdkui_exception_route_options_null)); } mRouteOptions = routeOptions; for (final OptionItem item : mSubItem) { if (item.getItemId() == R.string.msdkui_height) { ((NumericOptionItem) item).setValue(mRouteOptions.getTruckHeight()); } else if (item.getItemId() == R.string.msdkui_length) { ((NumericOptionItem) item).setValue(mRouteOptions.getTruckLength()); } else if (item.getItemId() == R.string.msdkui_width) { ((NumericOptionItem) item).setValue(mRouteOptions.getTruckWidth()); } else if (item.getItemId() == R.string.msdkui_limited_weight) { ((NumericOptionItem) item).setValue(mRouteOptions.getTruckLimitedWeight()); } else if (item.getItemId() == R.string.msdkui_weight_per_axle) { ((NumericOptionItem) item).setValue(mRouteOptions.getTruckWeightPerAxle()); } else if (item.getItemId() == R.string.msdkui_number_of_trailers) { ((NumericOptionItem) item).setInputType(InputType.TYPE_CLASS_NUMBER) .setValue(mRouteOptions.getTruckTrailersCount()); } else if (item.getItemId() == R.string.msdkui_truck_type) { ((SingleChoiceOptionItem) item).selectLabel(getTruckTypeLabel(mRouteOptions.getTruckType())); } else if (item.getItemId() == R.string.msdkui_violate_truck_options) { setRestriction(item); } } } }
TruckOptionsPanel extends OptionsPanel implements OptionItem.OnChangedListener { @SuppressWarnings({"PMD.CyclomaticComplexity"}) public void setRouteOptions(final RouteOptions routeOptions) { if (routeOptions == null) { throw new IllegalArgumentException(getContext().getString(R.string.msdkui_exception_route_options_null)); } mRouteOptions = routeOptions; for (final OptionItem item : mSubItem) { if (item.getItemId() == R.string.msdkui_height) { ((NumericOptionItem) item).setValue(mRouteOptions.getTruckHeight()); } else if (item.getItemId() == R.string.msdkui_length) { ((NumericOptionItem) item).setValue(mRouteOptions.getTruckLength()); } else if (item.getItemId() == R.string.msdkui_width) { ((NumericOptionItem) item).setValue(mRouteOptions.getTruckWidth()); } else if (item.getItemId() == R.string.msdkui_limited_weight) { ((NumericOptionItem) item).setValue(mRouteOptions.getTruckLimitedWeight()); } else if (item.getItemId() == R.string.msdkui_weight_per_axle) { ((NumericOptionItem) item).setValue(mRouteOptions.getTruckWeightPerAxle()); } else if (item.getItemId() == R.string.msdkui_number_of_trailers) { ((NumericOptionItem) item).setInputType(InputType.TYPE_CLASS_NUMBER) .setValue(mRouteOptions.getTruckTrailersCount()); } else if (item.getItemId() == R.string.msdkui_truck_type) { ((SingleChoiceOptionItem) item).selectLabel(getTruckTypeLabel(mRouteOptions.getTruckType())); } else if (item.getItemId() == R.string.msdkui_violate_truck_options) { setRestriction(item); } } } TruckOptionsPanel(final Context context);  TruckOptionsPanel(final Context context, final AttributeSet attrs);  TruckOptionsPanel(final Context context, final AttributeSet attrs, final int defStyleAttr); @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)  TruckOptionsPanel(final Context context, final AttributeSet attrs, final int defStyleAttr, final int defStyleRes); }
TruckOptionsPanel extends OptionsPanel implements OptionItem.OnChangedListener { @SuppressWarnings({"PMD.CyclomaticComplexity"}) public void setRouteOptions(final RouteOptions routeOptions) { if (routeOptions == null) { throw new IllegalArgumentException(getContext().getString(R.string.msdkui_exception_route_options_null)); } mRouteOptions = routeOptions; for (final OptionItem item : mSubItem) { if (item.getItemId() == R.string.msdkui_height) { ((NumericOptionItem) item).setValue(mRouteOptions.getTruckHeight()); } else if (item.getItemId() == R.string.msdkui_length) { ((NumericOptionItem) item).setValue(mRouteOptions.getTruckLength()); } else if (item.getItemId() == R.string.msdkui_width) { ((NumericOptionItem) item).setValue(mRouteOptions.getTruckWidth()); } else if (item.getItemId() == R.string.msdkui_limited_weight) { ((NumericOptionItem) item).setValue(mRouteOptions.getTruckLimitedWeight()); } else if (item.getItemId() == R.string.msdkui_weight_per_axle) { ((NumericOptionItem) item).setValue(mRouteOptions.getTruckWeightPerAxle()); } else if (item.getItemId() == R.string.msdkui_number_of_trailers) { ((NumericOptionItem) item).setInputType(InputType.TYPE_CLASS_NUMBER) .setValue(mRouteOptions.getTruckTrailersCount()); } else if (item.getItemId() == R.string.msdkui_truck_type) { ((SingleChoiceOptionItem) item).selectLabel(getTruckTypeLabel(mRouteOptions.getTruckType())); } else if (item.getItemId() == R.string.msdkui_violate_truck_options) { setRestriction(item); } } } TruckOptionsPanel(final Context context);  TruckOptionsPanel(final Context context, final AttributeSet attrs);  TruckOptionsPanel(final Context context, final AttributeSet attrs, final int defStyleAttr); @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)  TruckOptionsPanel(final Context context, final AttributeSet attrs, final int defStyleAttr, final int defStyleRes); RouteOptions getRouteOptions(); @SuppressWarnings({"PMD.CyclomaticComplexity"}) // This function is not complicated. void setRouteOptions(final RouteOptions routeOptions); @SuppressWarnings({"PMD.AvoidCatchingGenericException", "PMD.NcssCount", "PMD.CyclomaticComplexity", "PMD.NPathComplexity"}) @Override void onChanged(OptionItem item); }
TruckOptionsPanel extends OptionsPanel implements OptionItem.OnChangedListener { @SuppressWarnings({"PMD.CyclomaticComplexity"}) public void setRouteOptions(final RouteOptions routeOptions) { if (routeOptions == null) { throw new IllegalArgumentException(getContext().getString(R.string.msdkui_exception_route_options_null)); } mRouteOptions = routeOptions; for (final OptionItem item : mSubItem) { if (item.getItemId() == R.string.msdkui_height) { ((NumericOptionItem) item).setValue(mRouteOptions.getTruckHeight()); } else if (item.getItemId() == R.string.msdkui_length) { ((NumericOptionItem) item).setValue(mRouteOptions.getTruckLength()); } else if (item.getItemId() == R.string.msdkui_width) { ((NumericOptionItem) item).setValue(mRouteOptions.getTruckWidth()); } else if (item.getItemId() == R.string.msdkui_limited_weight) { ((NumericOptionItem) item).setValue(mRouteOptions.getTruckLimitedWeight()); } else if (item.getItemId() == R.string.msdkui_weight_per_axle) { ((NumericOptionItem) item).setValue(mRouteOptions.getTruckWeightPerAxle()); } else if (item.getItemId() == R.string.msdkui_number_of_trailers) { ((NumericOptionItem) item).setInputType(InputType.TYPE_CLASS_NUMBER) .setValue(mRouteOptions.getTruckTrailersCount()); } else if (item.getItemId() == R.string.msdkui_truck_type) { ((SingleChoiceOptionItem) item).selectLabel(getTruckTypeLabel(mRouteOptions.getTruckType())); } else if (item.getItemId() == R.string.msdkui_violate_truck_options) { setRestriction(item); } } } TruckOptionsPanel(final Context context);  TruckOptionsPanel(final Context context, final AttributeSet attrs);  TruckOptionsPanel(final Context context, final AttributeSet attrs, final int defStyleAttr); @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)  TruckOptionsPanel(final Context context, final AttributeSet attrs, final int defStyleAttr, final int defStyleRes); RouteOptions getRouteOptions(); @SuppressWarnings({"PMD.CyclomaticComplexity"}) // This function is not complicated. void setRouteOptions(final RouteOptions routeOptions); @SuppressWarnings({"PMD.AvoidCatchingGenericException", "PMD.NcssCount", "PMD.CyclomaticComplexity", "PMD.NPathComplexity"}) @Override void onChanged(OptionItem item);  }