Ejemplo n.º 1
0
  @Test
  public void should_create_obj_and_assign_references2()
      throws UserAlreadyExistsException, ProductCategoryOrLabelException {
    // given
    Product product1 = TestDataBuilder.build_blackIPhone();
    Product product2 = TestDataBuilder.build_whiteIPhone();
    Collection<Product> products = new ArrayList<Product>();
    products.add(product1);
    products.add(product2);

    User u1 = TestDataBuilder.build_johe_at_gmail();
    User u2 = TestDataBuilder.build_mahe_at_gmail();

    // when
    Shop store = Shop.createStore("rybnik", 200, 30.0);
    UserShop us1 = UserShop.createUserShop(u1, new Money(100l), null, null);
    UserShop us2 = UserShop.createUserShop(u2, new Money(200l), null, null);

    Collection<UserShop> uss = new ArrayList<UserShop>();
    uss.add(us1);
    uss.add(us2);
    store.setUserStores(uss);

    store.setProducts(products);

    // then
    assertNotNull(store);

    assertTrue(store.getProducts().contains(product1));
    assertTrue(store.getProducts().contains(product2));

    assertEquals(product1.getStore(), store);
    assertEquals(product2.getStore(), store);
  }
Ejemplo n.º 2
0
  @Test
  public void should_create_obj_and_assign_references() throws ProductCategoryOrLabelException {
    // given
    Product product1 = TestDataBuilder.build_blackIPhone();
    Product product2 = TestDataBuilder.build_whiteIPhone();

    // when
    Shop store = Shop.createStore("rybnik", 200, Arrays.asList(product1, product2));

    // then
    assertNotNull(store);

    assertTrue(store.getProducts().contains(product1));
    assertTrue(store.getProducts().contains(product2));

    assertEquals(product1.getStore(), store);
    assertEquals(product2.getStore(), store);
  }