Package br.com.six2six.fixturefactory

Source Code of br.com.six2six.fixturefactory.FixtureCircularReferenceTest

package br.com.six2six.fixturefactory;

import static org.junit.Assert.assertTrue;

import org.junit.BeforeClass;
import org.junit.Test;

import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader;
import br.com.six2six.fixturefactory.model.Item;
import br.com.six2six.fixturefactory.model.Order;

public class FixtureCircularReferenceTest {

  @BeforeClass
  public static void setUp() {
    FixtureFactoryLoader.loadTemplates("br.com.six2six.template");
  }
 
  @Test
  public void circularReference() {
    Order order = Fixture.from(Order.class).gimme("valid");
   
    for (Item item : order.getItems()) {
      assertTrue("order relationship with item should have the same reference", item.getOrder() == order);
    }
   
    assertTrue("payment one-to-one relationship should have the same reference", order == order.getPayment().getOrder());
  }
 
  @Test
  public void circularReferenceEspecifyProperty() {
    Order order = Fixture.from(Order.class).gimme("otherValid");
   
    for (Item item : order.getItems()) {
      assertTrue("order relationship with item should have the same reference", item.getOrder() == order);
    }
   
    assertTrue("payment one-to-one relationship should have the same reference", order == order.getPayment().getOrder());
  }

}
TOP

Related Classes of br.com.six2six.fixturefactory.FixtureCircularReferenceTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.