@Test public void shouldShowTvDrugCountWhenIsHistoricalEmergency() throws SQLException { program.setProgramCode(Constants.ESS_PROGRAM_CODE); RnRForm form = RnRForm.init(program, DateUtil.today()); form.setStatus(RnRForm.STATUS.AUTHORIZED); form.setSynced(true); form.setSubmittedTime(DateUtil.parseString("2016-01-22 11:33:44", DateUtil.DATE_TIME_FORMAT)); form.setEmergency(true); DbUtil.initialiseDao(RnRForm.class).assignEmptyForeignCollection(form, "rnrFormItemList"); form.getRnrFormItemList().add(new RnrFormItem()); RnRFormViewModel viewModel = RnRFormViewModel.buildEmergencyViewModel(form); viewHolder = getViewHolderByType(RnRFormViewModel.TYPE_SYNCED_HISTORICAL); viewHolder.populate(viewModel); assertThat(viewHolder.tvDrugCount.getVisibility(), is(View.VISIBLE)); assertThat(viewHolder.tvDrugCount.getText().toString(), is("1 drug ordered")); assertTrue(viewHolder.tvPeriod.getText().toString().equals("Emergency Requisition – 22 Jan 2016 11:33")); assertThat(viewHolder.tvMessage.getText().toString(), is(getStringResource(R.string.label_submitted_message, "Emergency requisition balancete", viewModel.getSyncedTime()))); assertThat(viewHolder.btnView.getText().toString(), is(getStringResource(R.string.btn_view_requisition, "Emergency requisition balancete"))); assertThat(viewHolder.ivDelete.getVisibility(), is(View.VISIBLE)); form.getRnrFormItemList().add(new RnrFormItem()); viewHolder.populate(viewModel); assertThat(viewHolder.tvDrugCount.getText().toString(), is("2 drugs ordered")); }
@SuppressLint("StringFormatMatches") public void populate(final RnRFormViewModel model) { switch (model.getType()) { case RnRFormViewModel.TYPE_MISSED_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_previous_period_missing)), R.drawable.ic_description, R.color.color_draft_title, color_white); break; case RnRFormViewModel.TYPE_FIRST_MISSED_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_missed_period)), R.drawable.ic_description, R.color.color_select_title, color_white); setupButton(model, context.getString(R.string.btn_select_close_period)); setupButtonColor(); break; case RnRFormViewModel.TYPE_CANNOT_DO_MONTHLY_INVENTORY: showCannotDoMonthlyInventory(model); break; case RnRFormViewModel.TYPE_UNCOMPLETE_INVENTORY_IN_CURRENT_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_uncompleted_physical_inventory_message, model.getName(), model.getName())), R.drawable.ic_description, R.color.color_draft_title, color_white); setupButton(model, context.getString(R.string.btn_view_uncompleted_physical_inventory)); break; case RnRFormViewModel.TYPE_INVENTORY_DONE: case RnRFormViewModel.TYPE_CLOSE_OF_PERIOD_SELECTED: populateRnrFormNotBeCreatedView(model); break; case RnRFormViewModel.TYPE_CREATED_BUT_UNCOMPLETED: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_incomplete_requisition, model.getName())), R.drawable.ic_description, R.color.color_draft_title, color_white); setupButton(model, context.getString(R.string.btn_view_incomplete_requisition, model.getName())); break; case RnRFormViewModel.TYPE_UNSYNCED_HISTORICAL: populateRnrFormUnsyncedMessage(model); break; case RnRFormViewModel.TYPE_SYNCED_HISTORICAL: populateSyncedHistorical(model); break; case RnRFormViewModel.TYPE_INACTIVE: populateRnrFormInActiveCreatedView(model); break; } }
RnRFormViewHolder extends BaseViewHolder { @SuppressLint("StringFormatMatches") public void populate(final RnRFormViewModel model) { switch (model.getType()) { case RnRFormViewModel.TYPE_MISSED_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_previous_period_missing)), R.drawable.ic_description, R.color.color_draft_title, color_white); break; case RnRFormViewModel.TYPE_FIRST_MISSED_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_missed_period)), R.drawable.ic_description, R.color.color_select_title, color_white); setupButton(model, context.getString(R.string.btn_select_close_period)); setupButtonColor(); break; case RnRFormViewModel.TYPE_CANNOT_DO_MONTHLY_INVENTORY: showCannotDoMonthlyInventory(model); break; case RnRFormViewModel.TYPE_UNCOMPLETE_INVENTORY_IN_CURRENT_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_uncompleted_physical_inventory_message, model.getName(), model.getName())), R.drawable.ic_description, R.color.color_draft_title, color_white); setupButton(model, context.getString(R.string.btn_view_uncompleted_physical_inventory)); break; case RnRFormViewModel.TYPE_INVENTORY_DONE: case RnRFormViewModel.TYPE_CLOSE_OF_PERIOD_SELECTED: populateRnrFormNotBeCreatedView(model); break; case RnRFormViewModel.TYPE_CREATED_BUT_UNCOMPLETED: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_incomplete_requisition, model.getName())), R.drawable.ic_description, R.color.color_draft_title, color_white); setupButton(model, context.getString(R.string.btn_view_incomplete_requisition, model.getName())); break; case RnRFormViewModel.TYPE_UNSYNCED_HISTORICAL: populateRnrFormUnsyncedMessage(model); break; case RnRFormViewModel.TYPE_SYNCED_HISTORICAL: populateSyncedHistorical(model); break; case RnRFormViewModel.TYPE_INACTIVE: populateRnrFormInActiveCreatedView(model); break; } } }
RnRFormViewHolder extends BaseViewHolder { @SuppressLint("StringFormatMatches") public void populate(final RnRFormViewModel model) { switch (model.getType()) { case RnRFormViewModel.TYPE_MISSED_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_previous_period_missing)), R.drawable.ic_description, R.color.color_draft_title, color_white); break; case RnRFormViewModel.TYPE_FIRST_MISSED_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_missed_period)), R.drawable.ic_description, R.color.color_select_title, color_white); setupButton(model, context.getString(R.string.btn_select_close_period)); setupButtonColor(); break; case RnRFormViewModel.TYPE_CANNOT_DO_MONTHLY_INVENTORY: showCannotDoMonthlyInventory(model); break; case RnRFormViewModel.TYPE_UNCOMPLETE_INVENTORY_IN_CURRENT_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_uncompleted_physical_inventory_message, model.getName(), model.getName())), R.drawable.ic_description, R.color.color_draft_title, color_white); setupButton(model, context.getString(R.string.btn_view_uncompleted_physical_inventory)); break; case RnRFormViewModel.TYPE_INVENTORY_DONE: case RnRFormViewModel.TYPE_CLOSE_OF_PERIOD_SELECTED: populateRnrFormNotBeCreatedView(model); break; case RnRFormViewModel.TYPE_CREATED_BUT_UNCOMPLETED: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_incomplete_requisition, model.getName())), R.drawable.ic_description, R.color.color_draft_title, color_white); setupButton(model, context.getString(R.string.btn_view_incomplete_requisition, model.getName())); break; case RnRFormViewModel.TYPE_UNSYNCED_HISTORICAL: populateRnrFormUnsyncedMessage(model); break; case RnRFormViewModel.TYPE_SYNCED_HISTORICAL: populateSyncedHistorical(model); break; case RnRFormViewModel.TYPE_INACTIVE: populateRnrFormInActiveCreatedView(model); break; } } RnRFormViewHolder(View inflate, RnRFormItemClickListener itemClickListener); }
RnRFormViewHolder extends BaseViewHolder { @SuppressLint("StringFormatMatches") public void populate(final RnRFormViewModel model) { switch (model.getType()) { case RnRFormViewModel.TYPE_MISSED_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_previous_period_missing)), R.drawable.ic_description, R.color.color_draft_title, color_white); break; case RnRFormViewModel.TYPE_FIRST_MISSED_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_missed_period)), R.drawable.ic_description, R.color.color_select_title, color_white); setupButton(model, context.getString(R.string.btn_select_close_period)); setupButtonColor(); break; case RnRFormViewModel.TYPE_CANNOT_DO_MONTHLY_INVENTORY: showCannotDoMonthlyInventory(model); break; case RnRFormViewModel.TYPE_UNCOMPLETE_INVENTORY_IN_CURRENT_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_uncompleted_physical_inventory_message, model.getName(), model.getName())), R.drawable.ic_description, R.color.color_draft_title, color_white); setupButton(model, context.getString(R.string.btn_view_uncompleted_physical_inventory)); break; case RnRFormViewModel.TYPE_INVENTORY_DONE: case RnRFormViewModel.TYPE_CLOSE_OF_PERIOD_SELECTED: populateRnrFormNotBeCreatedView(model); break; case RnRFormViewModel.TYPE_CREATED_BUT_UNCOMPLETED: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_incomplete_requisition, model.getName())), R.drawable.ic_description, R.color.color_draft_title, color_white); setupButton(model, context.getString(R.string.btn_view_incomplete_requisition, model.getName())); break; case RnRFormViewModel.TYPE_UNSYNCED_HISTORICAL: populateRnrFormUnsyncedMessage(model); break; case RnRFormViewModel.TYPE_SYNCED_HISTORICAL: populateSyncedHistorical(model); break; case RnRFormViewModel.TYPE_INACTIVE: populateRnrFormInActiveCreatedView(model); break; } } RnRFormViewHolder(View inflate, RnRFormItemClickListener itemClickListener); @SuppressLint("StringFormatMatches") void populate(final RnRFormViewModel model); }
RnRFormViewHolder extends BaseViewHolder { @SuppressLint("StringFormatMatches") public void populate(final RnRFormViewModel model) { switch (model.getType()) { case RnRFormViewModel.TYPE_MISSED_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_previous_period_missing)), R.drawable.ic_description, R.color.color_draft_title, color_white); break; case RnRFormViewModel.TYPE_FIRST_MISSED_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_missed_period)), R.drawable.ic_description, R.color.color_select_title, color_white); setupButton(model, context.getString(R.string.btn_select_close_period)); setupButtonColor(); break; case RnRFormViewModel.TYPE_CANNOT_DO_MONTHLY_INVENTORY: showCannotDoMonthlyInventory(model); break; case RnRFormViewModel.TYPE_UNCOMPLETE_INVENTORY_IN_CURRENT_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_uncompleted_physical_inventory_message, model.getName(), model.getName())), R.drawable.ic_description, R.color.color_draft_title, color_white); setupButton(model, context.getString(R.string.btn_view_uncompleted_physical_inventory)); break; case RnRFormViewModel.TYPE_INVENTORY_DONE: case RnRFormViewModel.TYPE_CLOSE_OF_PERIOD_SELECTED: populateRnrFormNotBeCreatedView(model); break; case RnRFormViewModel.TYPE_CREATED_BUT_UNCOMPLETED: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_incomplete_requisition, model.getName())), R.drawable.ic_description, R.color.color_draft_title, color_white); setupButton(model, context.getString(R.string.btn_view_incomplete_requisition, model.getName())); break; case RnRFormViewModel.TYPE_UNSYNCED_HISTORICAL: populateRnrFormUnsyncedMessage(model); break; case RnRFormViewModel.TYPE_SYNCED_HISTORICAL: populateSyncedHistorical(model); break; case RnRFormViewModel.TYPE_INACTIVE: populateRnrFormInActiveCreatedView(model); break; } } RnRFormViewHolder(View inflate, RnRFormItemClickListener itemClickListener); @SuppressLint("StringFormatMatches") void populate(final RnRFormViewModel model);  }