@Test public void shouldGetStockCardRnr() throws LMISException { ptvRepository = spy(ptvRepository); ArrayList<StockCard> stockCards = new ArrayList<>(); Product product = new Product(); product.setCode("01A01"); product.setId(1234L); StockCard stockCard = new StockCardBuilder() .setCreateDate(new Date()) .setProduct(product) .build(); stockCard.setCreatedAt(DateUtil.parseString("10/10/2015", DateUtil.SIMPLE_DATE_FORMAT)); stockCards.add(stockCard); RnRForm form = new RnRForm(); form.setPeriodBegin(DateUtil.parseString("9/21/2015", DateUtil.SIMPLE_DATE_FORMAT)); form.setPeriodEnd(DateUtil.parseString("10/20/2015", DateUtil.SIMPLE_DATE_FORMAT)); final Program program = new Program(Constants.PTV_PROGRAM_CODE, Constants.PTV_PROGRAM_CODE, null, false, null, null); form.setProgram(program); List<String> mockProgramCode = new ArrayList<>(); mockProgramCode.add(program.getProgramCode()); ProductProgram productProgram = new ProductProgram(); productProgram.setCategory("Adult"); List<Long> mockProductIds = new ArrayList<>(); mockProductIds.add(product.getId()); List<Product> products = new ArrayList<>(); products.add(product); when(mockProductProgramRepository.queryActiveProductIdsByProgramsWithKits(anyListOf(String.class), anyBoolean())) .thenReturn(mockProductIds); when(mockProductProgramRepository.queryByCode(anyString(), anyListOf(String.class))).thenReturn(productProgram); when(mockProgramRepository.queryProgramCodesByProgramCodeOrParentCode(anyString())).thenReturn(mockProgramCode); when(mockProductRepository.queryProductsByProductIds(anyListOf(Long.class))).thenReturn(products); when(mockProgramRepository.queryByCode(anyString())).thenReturn(program); when(mockServiceFormRepository.listAllActiveWithProgram(any())).thenReturn(newArrayList()); doReturn(newArrayList(form)).when(ptvRepository).listInclude(any(RnRForm.Emergency.class), anyString()); List<RnrFormItem> rnrFormItems = ptvRepository.generateRnrFormItems(form, stockCards); assertThat(rnrFormItems.get(0).getProduct(), is(product)); final Service service = new Service(); when(mockServiceFormRepository.listAllActiveWithProgram(any())).thenReturn(newArrayList(service)); rnrFormItems = ptvRepository.generateRnrFormItems(form, stockCards); assertThat(rnrFormItems.get(0).getServiceItemListWrapper().get(0).getService(), is(service)); }
@Override public List<RnrFormItem> generateRnrFormItems(RnRForm form, List<StockCard> stockCards) throws LMISException { List<RnrFormItem> rnrFormItems = super.generateRnrFormItems(form, stockCards); return fillAllPTVProduct(form, rnrFormItems); }
PTVRepository extends RnrFormRepository { @Override public List<RnrFormItem> generateRnrFormItems(RnRForm form, List<StockCard> stockCards) throws LMISException { List<RnrFormItem> rnrFormItems = super.generateRnrFormItems(form, stockCards); return fillAllPTVProduct(form, rnrFormItems); } }
PTVRepository extends RnrFormRepository { @Override public List<RnrFormItem> generateRnrFormItems(RnRForm form, List<StockCard> stockCards) throws LMISException { List<RnrFormItem> rnrFormItems = super.generateRnrFormItems(form, stockCards); return fillAllPTVProduct(form, rnrFormItems); } @Inject  PTVRepository(Context context); }
PTVRepository extends RnrFormRepository { @Override public List<RnrFormItem> generateRnrFormItems(RnRForm form, List<StockCard> stockCards) throws LMISException { List<RnrFormItem> rnrFormItems = super.generateRnrFormItems(form, stockCards); return fillAllPTVProduct(form, rnrFormItems); } @Inject  PTVRepository(Context context); @Override List<RnrFormItem> generateRnrFormItems(RnRForm form, List<StockCard> stockCards); }
PTVRepository extends RnrFormRepository { @Override public List<RnrFormItem> generateRnrFormItems(RnRForm form, List<StockCard> stockCards) throws LMISException { List<RnrFormItem> rnrFormItems = super.generateRnrFormItems(form, stockCards); return fillAllPTVProduct(form, rnrFormItems); } @Inject  PTVRepository(Context context); @Override List<RnrFormItem> generateRnrFormItems(RnRForm form, List<StockCard> stockCards);  }