Ejemplo n.º 1
0
  @Test
  public void localConfigurationObjectsInCollectionsCanBeOverridenWithDefaultValue() {
    final Person uniqueSize1 =
        ObjectG.unique(Person.class, ObjectG.config().setObjectsInCollection(1));

    assertEquals("uniqueSize1", 1, uniqueSize1.getEmployee2Addresses().size());
  }
Ejemplo n.º 2
0
  @Test
  public void testConfigurationWillBeMerged() {
    final ClassWithIPerson classWithPerson =
        ObjectG.unique(ClassWithIPerson.class, ObjectG.config().when(Tour.class).setValue(null));

    assertLocalConfigurationWasApplied(classWithPerson);
    assertNull(classWithPerson.getTour());
  }
Ejemplo n.º 3
0
 @Before
 public void setup() {
   ObjectG.configLocal(
       ObjectG.config()
           .when(IPerson.class)
           .useClass(Person.class)
           .setObjectsInCollection(2)
           .done());
 }
  @Test(expected = PostProcessingException.class)
  public void throwsWhenNotExistingProperty() {
    ExpressionPostProcessor expressionPostProcessor =
        new ExpressionPostProcessor("notExistingProperty", this);

    Person person = ObjectG.unique(Person.class);
    expressionPostProcessor.process(new GenerationConfiguration(), person);
  }
  @Test
  public void handlerIsCalled() {
    ExpressionPostProcessor expressionPostProcessor =
        new ExpressionPostProcessor("employee2Addresses[0].id", this);

    Person person = ObjectG.unique(Person.class);
    expressionPostProcessor.process(new GenerationConfiguration(), person);

    assertEquals("handleGeneratedObject", person, handleGeneratedObject);
    assertNotNull("expressionGenerationContext", handleContextForExpression);
  }
Ejemplo n.º 6
0
 @Test
 public void localConfigurationCanDefineObjectsInCollections() {
   final Person unique = ObjectG.unique(Person.class);
   assertEquals(2, unique.getEmployee2Addresses().size());
 }
Ejemplo n.º 7
0
 // testOne and testTwo show that configuration is applied to all test methods
 @Test
 public void testTwo() {
   assertLocalConfigurationWasApplied(ObjectG.unique(ClassWithIPerson.class));
 }
Ejemplo n.º 8
0
 public Tour generateChild() {
   return ObjectG.unique(Tour.class);
 }
Ejemplo n.º 9
0
 public void setupChild() {
   ObjectG.configLocal(ObjectG.config().setObjectsInCollection(OBJECTS_IN_COLLECTION));
 }
Ejemplo n.º 10
0
 public Tour generateParent() {
   return ObjectG.unique(Tour.class);
 }