@Test public void shouldDeserializeStockCardWithLots() throws Exception { Product product = ProductBuilder.buildAdultProduct(); product.setCode("08R01"); when(mockProductRepository.getByCode("08R01")).thenReturn(product); String json = JsonFileReader.readJson(getClass(), "StockCardResponseWithLots.json"); StockCard stockCard = stockCardAdapter.deserialize(new JsonParser().parse(json), null, null); assertNotNull(json); List<LotOnHand> lotsOnHandWrapper = stockCard.getLotOnHandListWrapper(); assertThat(lotsOnHandWrapper.size(), is(2)); assertThat(lotsOnHandWrapper.get(0).getLot().getLotNumber(), is("test3")); assertThat(lotsOnHandWrapper.get(0).getQuantityOnHand(), is(300L)); assertThat(lotsOnHandWrapper.get(0).getLot().getExpirationDate(), is(DateUtil.parseString("2016-07-31", DateUtil.DB_DATE_FORMAT))); List<StockMovementItem> stockMovementItems = stockCard.getStockMovementItemsWrapper(); assertEquals(1, stockMovementItems.size()); assertEquals(700, stockMovementItems.get(0).getMovementQuantity()); assertEquals(700, stockMovementItems.get(0).getStockOnHand()); List<LotMovementItem> lotMovementItems = stockMovementItems.get(0).getLotMovementItemListWrapper(); assertEquals(2, lotMovementItems.size()); assertThat(lotMovementItems.get(0).getMovementQuantity(), is(300L)); assertThat(lotMovementItems.get(1).getMovementQuantity(), is(400L)); assertEquals("08R01", lotMovementItems.get(0).getLot().getProduct().getCode()); assertEquals("08R01", lotMovementItems.get(1).getLot().getProduct().getCode()); }
@Override public StockCard deserialize(JsonElement json, java.lang.reflect.Type typeOfT, JsonDeserializationContext context) throws JsonParseException { StockCard stockCard = gson.fromJson(json, StockCard.class); try { setupStockCard(stockCard); setupLotOnHandList(stockCard); setupProductAndStockCardOfMovementItems(stockCard); } catch (LMISException e) { new LMISException(e,"StockCardAdapter.deserialize").reportToFabric(); } return stockCard; }
StockCardAdapter implements JsonDeserializer<StockCard> { @Override public StockCard deserialize(JsonElement json, java.lang.reflect.Type typeOfT, JsonDeserializationContext context) throws JsonParseException { StockCard stockCard = gson.fromJson(json, StockCard.class); try { setupStockCard(stockCard); setupLotOnHandList(stockCard); setupProductAndStockCardOfMovementItems(stockCard); } catch (LMISException e) { new LMISException(e,"StockCardAdapter.deserialize").reportToFabric(); } return stockCard; } }
StockCardAdapter implements JsonDeserializer<StockCard> { @Override public StockCard deserialize(JsonElement json, java.lang.reflect.Type typeOfT, JsonDeserializationContext context) throws JsonParseException { StockCard stockCard = gson.fromJson(json, StockCard.class); try { setupStockCard(stockCard); setupLotOnHandList(stockCard); setupProductAndStockCardOfMovementItems(stockCard); } catch (LMISException e) { new LMISException(e,"StockCardAdapter.deserialize").reportToFabric(); } return stockCard; } @Inject  StockCardAdapter(); }
StockCardAdapter implements JsonDeserializer<StockCard> { @Override public StockCard deserialize(JsonElement json, java.lang.reflect.Type typeOfT, JsonDeserializationContext context) throws JsonParseException { StockCard stockCard = gson.fromJson(json, StockCard.class); try { setupStockCard(stockCard); setupLotOnHandList(stockCard); setupProductAndStockCardOfMovementItems(stockCard); } catch (LMISException e) { new LMISException(e,"StockCardAdapter.deserialize").reportToFabric(); } return stockCard; } @Inject  StockCardAdapter(); @Override StockCard deserialize(JsonElement json, java.lang.reflect.Type typeOfT, JsonDeserializationContext context); void setupStockCardExpireDates(StockCard stockCard); void setupProductAndStockCardOfMovementItems(StockCard stockCard); }
StockCardAdapter implements JsonDeserializer<StockCard> { @Override public StockCard deserialize(JsonElement json, java.lang.reflect.Type typeOfT, JsonDeserializationContext context) throws JsonParseException { StockCard stockCard = gson.fromJson(json, StockCard.class); try { setupStockCard(stockCard); setupLotOnHandList(stockCard); setupProductAndStockCardOfMovementItems(stockCard); } catch (LMISException e) { new LMISException(e,"StockCardAdapter.deserialize").reportToFabric(); } return stockCard; } @Inject  StockCardAdapter(); @Override StockCard deserialize(JsonElement json, java.lang.reflect.Type typeOfT, JsonDeserializationContext context); void setupStockCardExpireDates(StockCard stockCard); void setupProductAndStockCardOfMovementItems(StockCard stockCard);  }