@Test public void shouldDeserializeStockCard() throws Exception { Product product = ProductBuilder.buildAdultProduct(); product.setCode("08S42"); when(mockProductRepository.getByCode("08S42")).thenReturn(product); String json = JsonFileReader.readJson(getClass(), "StockCardWithMovement.json"); StockCard stockCard = stockCardAdapter.deserialize(new JsonParser().parse(json), null, null); assertNotNull(json); assertThat(stockCard.getStockOnHand(), is(480L)); assertThat(stockCard.getProduct().getCode(), is("08S42")); List<StockMovementItem> stockMovementItemsWrapper = stockCard.getStockMovementItemsWrapper(); assertThat(stockMovementItemsWrapper.size(), is(3)); }
@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);  }