Пример #1
0
  @Before
  public void setUp() {
    requestFactory = RequestFactoryHelper.create(PizzaRequestFactory.class);
    dao = RequestFactoryHelper.getService(PizzaDao.class);

    pizzaManager = new PizzaManager(requestFactory);
  }
Пример #2
0
  @Test
  public void findPizzaById() {

    String name = "Funghi";
    Pizza expectedPizza = createPizza(name, Collections.singletonList(new Ingredient()));
    Long id = (long) 5;

    when(dao.findById(id)).thenReturn(expectedPizza);

    Receiver<PizzaProxy> receiver = mock(Receiver.class);
    pizzaManager.findById(id, receiver);

    // Get returned GWT entity proxy
    PizzaProxy returnedPizza = RequestFactoryHelper.captureResult(receiver);

    assertEquals(name, returnedPizza.getName());
    assertEquals(1, returnedPizza.getIngredients().size());
  }