MMIARepository extends RnrFormRepository { @Override protected List<BaseInfoItem> generateBaseInfoItems(final RnRForm form, ReportType type) { if (ReportType.NEW != type) { ArrayList<String> attrs = new ArrayList<>(); attrs.add(ATTR_NEW_PATIENTS); attrs.add(ATTR_SUSTAINING); attrs.add(ATTR_ALTERATION); attrs.add(ATTR_PTV); attrs.add(ATTR_PPE); attrs.add(ATTR_TOTAL_MONTH_DISPENSE); attrs.add(ATTR_TOTAL_PATIENTS); return FluentIterable.from(attrs) .transform(attr -> new BaseInfoItem(attr, BaseInfoItem.TYPE.INT, form, "", 0)) .toList(); } Map<String, String> mAttrs = new HashMap<>(); initAttrs(mAttrs); initDisplayOrder(); return FluentIterable.from(mAttrs.keySet()) .transform(key -> new BaseInfoItem(key, BaseInfoItem.TYPE.INT, form, mAttrs.get(key), getDisplayOrder(key))) .toSortedList((o1, o2) -> o1.getDisplayOrder() - o2.getDisplayOrder()); } @Inject  MMIARepository(Context context); long getTotalPatients(RnRForm form); @Override List<RnrFormItem> generateRnrFormItems(RnRForm form, List<StockCard> stockCards); @InjectResource(R.string.table_trav)
    public String ATTR_TABLE_TRAV; @InjectResource(R.string.table_trav_label_new)
    public String ATTR_TABLE_TRAV_NEW; @InjectResource(R.string.table_trav_label_maintenance)
    public String ATTR_TABLE_TRAV_MAINTENANCE; @InjectResource(R.string.table_trav_label_alteration)
    public String ATTR_TABLE_TRAV_ALTERATION; @InjectResource(R.string.table_trav_label_transit)
    public String ATTR_TABLE_TRAV_TRANSIT; @InjectResource(R.string.table_trav_label_transfers)
    public String ATTR_TABLE_TRAV_TRANSFER; @InjectResource(R.string.table_dispensed)
    public String ATTR_TABLE_DISPENSED; @InjectResource(R.string.table_dispensed_label_dt)
    public String ATTR_TABLE_DISPENSED_DT; @InjectResource(R.string.table_dispensed_label_dm)
    public String ATTR_TABLE_DISPENSED_DM; @InjectResource(R.string.table_dispensed_label_therapeutic)
    public String ATTR_TABLE_DISPENSED_THERAPEUTIC; @InjectResource(R.string.table_dispensed_label_ds)
    public String ATTR_TABLE_DISPENSED_DS; @InjectResource(R.string.table_patients)
    public String ATTR_TABLE_PATIENTS; @InjectResource(R.string.table_patients_adults)
    public String ATTR_TABLE_PATIENTS_ADULTS; @InjectResource(R.string.table_patients_0to4)
    public String ATTR_TABLE_PATIENTS_0TO4; @InjectResource(R.string.table_patients_5to9)
    public String ATTR_TABLE_PATIENTS_5TO9; @InjectResource(R.string.table_patients_10to14)
    public String ATTR_TABLE_PATIENTS_10TO14; @InjectResource(R.string.table_prophylaxis)
    public String ATTR_TABLE_PROPHYLAXIS; @InjectResource(R.string.table_prophylaxis_ppe)
    public String ATTR_TABLE_PROPHYLAXIS_PPE; @InjectResource(R.string.table_prophylaxis_prep)
    public String ATTR_TABLE_PROPHYLAXIS_PREP; @InjectResource(R.string.table_prophylaxis_child)
    public String ATTR_TABLE_PROPHYLAXIS_CHILD; @InjectResource(R.string.table_prophylaxis_total)
    public String ATTR_TABLE_PROPHYLAXIS_TOTAL; @InjectResource(R.string.mmia_1stline)
    public String ATTR_REGIME_TYPE_FIRST_LINE; @InjectResource(R.string.mmia_2ndline)
    public String ATTR_REGIME_TYPE_SECOND_LINE; @InjectResource(R.string.mmia_3rdline)
    public String ATTR_REGIME_TYPE_THIRD_LINE; @InjectResource(R.string.label_new_patients)
    public String ATTR_NEW_PATIENTS; @InjectResource(R.string.label_sustaining)
    public String ATTR_SUSTAINING; @InjectResource(R.string.label_alteration)
    public String ATTR_ALTERATION; @InjectResource(R.string.label_total_month_dispense)
    public String ATTR_TOTAL_MONTH_DISPENSE; @InjectResource(R.string.label_total_patients)
    public String ATTR_TOTAL_PATIENTS; @InjectResource(R.string.label_ptv)
    public String ATTR_PTV; @InjectResource(R.string.label_ppe)
    public String ATTR_PPE; }
@Test public void shouldGenerateBaseInfoItems() { RnRForm rnRForm = new RnRForm(); List<BaseInfoItem> baseInfoItems = mmiaRepository.generateBaseInfoItems(rnRForm, MMIARepository.ReportType.OLD); assertThat(baseInfoItems.size(), is(7)); assertThat(baseInfoItems.get(0).getName(), is(mmiaRepository.ATTR_NEW_PATIENTS)); assertThat(baseInfoItems.get(3).getName(), is(mmiaRepository.ATTR_PTV)); assertThat(baseInfoItems.get(baseInfoItems.size() - 1).getName(), is(mmiaRepository.ATTR_TOTAL_PATIENTS)); }
@Test public void shouldGenerateBaseInfoItemsNew() { RnRForm rnRForm = new RnRForm(); List<BaseInfoItem> baseInfoItems = mmiaRepository.generateBaseInfoItems(rnRForm, MMIARepository.ReportType.NEW); assertThat(baseInfoItems.size(), is(17)); assertThat(baseInfoItems.get(0).getName(), is(mmiaRepository.ATTR_TABLE_TRAV_NEW)); assertThat(baseInfoItems.get(1).getName(), is(mmiaRepository.ATTR_TABLE_TRAV_MAINTENANCE)); assertThat(baseInfoItems.get(2).getName(), is(mmiaRepository.ATTR_TABLE_TRAV_ALTERATION)); assertThat(baseInfoItems.get(3).getName(), is(mmiaRepository.ATTR_TABLE_TRAV_TRANSIT)); assertThat(baseInfoItems.get(4).getName(), is(mmiaRepository.ATTR_TABLE_TRAV_TRANSFER)); assertThat(baseInfoItems.get(5).getName(), is(mmiaRepository.ATTR_TABLE_DISPENSED_DM)); assertThat(baseInfoItems.get(6).getName(), is(mmiaRepository.ATTR_TABLE_DISPENSED_DT)); assertThat(baseInfoItems.get(7).getName(), is(mmiaRepository.ATTR_TABLE_DISPENSED_DS)); assertThat(baseInfoItems.get(8).getName(), is(mmiaRepository.ATTR_TABLE_DISPENSED_THERAPEUTIC)); assertThat(baseInfoItems.get(9).getName(), is(mmiaRepository.ATTR_TABLE_PATIENTS_ADULTS)); assertThat(baseInfoItems.get(10).getName(), is(mmiaRepository.ATTR_TABLE_PATIENTS_0TO4)); assertThat(baseInfoItems.get(11).getName(), is(mmiaRepository.ATTR_TABLE_PATIENTS_5TO9)); assertThat(baseInfoItems.get(12).getName(), is(mmiaRepository.ATTR_TABLE_PATIENTS_10TO14)); assertThat(baseInfoItems.get(13).getName(), is(mmiaRepository.ATTR_TABLE_PROPHYLAXIS_PPE)); assertThat(baseInfoItems.get(14).getName(), is(mmiaRepository.ATTR_TABLE_PROPHYLAXIS_PREP)); assertThat(baseInfoItems.get(15).getName(), is(mmiaRepository.ATTR_TABLE_PROPHYLAXIS_CHILD)); assertThat(baseInfoItems.get(16).getName(), is(mmiaRepository.ATTR_TABLE_PROPHYLAXIS_TOTAL)); }