Package br.com.six2six.fixturefactory

Examples of br.com.six2six.fixturefactory.Rule


public class ProposalTemplate implements TemplateLoader {

  @Override
  public void load() {
    Fixture.of(SimpleProposal.class).addTemplate("valid", new Rule(){{
      add("item.order.id", "123456");
    }});
  }
View Full Code Here


public class InnerClassTemplate implements TemplateLoader {

  @Override
  public void load() {
    Fixture.of(Owner.class).addTemplate("valid", new Rule(){{
      add("inner", one(Owner.Inner.class, "valid"));
    }});

    Fixture.of(Owner.class).addTemplate("chained", new Rule(){{
        add("inner.id", "333");
    }});

    Fixture.of(Owner.Inner.class).addTemplate("valid", new Rule(){{
      add("id", "222");
    }});
  }
View Full Code Here

public class InvoiceTemplate implements TemplateLoader {

  @Override
  public void load() {
    Fixture.of(Invoice.class).addTemplate("valid", new Rule(){{
      add("id", regex("\\d{3,5}"));
      add("ammount", random(BigDecimal.class, new MathContext(2)));
      add("dueDate", beforeDate("2011-04-08", new SimpleDateFormat("yyyy-MM-dd")));
     
    }}).addTemplate("previousInvoices", new Rule(){{
      add("id", regex("\\d{3,5}"));
      add("ammount", random(BigDecimal.class, range(new BigDecimal("45.89"), new BigDecimal("58.67"))));
      add("dueDate", sequenceDate("2011-04-01", new SimpleDateFormat("yyyy-MM-dd"), decrement(1).month()));
     
    }}).addTemplate("nextInvoices", new Rule(){{
      add("id", regex("\\d{3,5}"));
      add("ammount", random(new BigDecimal("58.67"), new BigDecimal("45.89")));
      add("dueDate", sequenceDate("2011-04-30", increment(1).day()));
    }});
  }
View Full Code Here

public class UserTemplate implements TemplateLoader {

  @Override
  public void load() {
    Fixture.of(User.class).addTemplate("anyValidUser", new Rule(){{
      add("name", name());
      add("login", random("login1", "login2"));
      add("password", "madona");
      add("gender", random(Gender.class));
      add("email", "${login}@gmail.com");
    }}
    ).addTemplate("validFemaleUser", new Rule(){{
      add("name", name(Gender.FEMALE));
      add("login", "${name}");
      add("password", name(Gender.MALE));
      add("gender", Gender.FEMALE);
      add("email", "duck@gmail.com");
View Full Code Here

public class StudentTemplate implements TemplateLoader {

  @Override
  public void load() {
    Fixture.of(Student.class).addTemplate("valid", new Rule(){{
      add("id", sequence(1L, 1));
      add("firstName", firstName());
      add("lastName", lastName());
      add("gender", random(Gender.class));
      add("bestScore", regex("\\d{2}\\.\\d{3}"));
      add("testsTaken", regex("\\d{1}1"));
      add("idCardNumber", regex("\\d{6}"));
    }}
    ).addTemplate("validFemaleStudent", new Rule(){{
      add("id", sequence(200L, 2));
      add("firstName", firstName(Gender.FEMALE));
      add("lastName", lastName());
      add("gender", Gender.FEMALE);
    }}
    ).addTemplate("validMaleStudent", new Rule() {{
      add("id", regex("\\d{3,5}"));
      add("firstName", firstName(Gender.MALE));
      add("lastName", lastName());
      add("gender", Gender.MALE);
    }});
   
    final Sequence<Number> numberSequence = new NumberSequence(1L, 1);
   
    Fixture.of(Student.class).addTemplate("sharedSequence", new Rule(){{
      add("id", sequence(numberSequence));
    }}
    ).addTemplate("otherSharedSequence", new Rule(){{
      add("id", sequence(numberSequence));
    }});
   
    Fixture.of(Student.class).addTemplate("defaultNumberSequence", new Rule() {{
      add("id", sequence(Long.class));
    }})
  }
View Full Code Here

public class ImmutableTemplate implements TemplateLoader {

  @Override
  public void load() {
    Fixture.of(Immutable.class)
    .addTemplate("twoParameterConstructor", new Rule(){{
      add("propertyA", regex("\\w{8}"));
      add("propertyB", random(1000L, 2000L));
      add("immutableInner", one(ImmutableInner.class, "immutable"));
    }})
    .addTemplate("threeParameterConstructor", new Rule(){{
      add("propertyB", random(1000L, 2000L));
      add("propertyC", regex("\\w{8}"));
      add("immutableInner", one(ImmutableInner.class, "immutable"));
      add("address", one(Address.class, "valid"));
    }})
    .addTemplate("fullConstructor", new Rule(){{
      add("propertyA", regex("\\w{8}"));
      add("propertyB", random(1000L, 2000L));
      add("propertyC", "${propertyA} based");
      add("date", instant("now"));
      add("address", one(Address.class, "valid"));
    }});
 
    Fixture.of(ImmutableInner.class).addTemplate("immutable", new Rule(){{
      add("propertyD", regex("\\w{8}"));
    }});
 
    Fixture.of(Address.class).addTemplate("valid", new Rule(){{
      add("id", random(Long.class, range(1L, 100L)));
      add("street", random("Paulista Avenue", "Ibirapuera Avenue"));
      add("city", one(City.class, "valid"));
      add("state", "SP");
      add("country", "Brazil");
      add("zipCode", random("06608000", "17720000"));
    }});
 
    Fixture.of(Route.class)
        .addTemplate("valid", new Rule(){{
          add("id", one(RouteId.class, "valid"));
          add("cities", has(2).of(City.class, "valid"));
        }})
        .addTemplate("chainedId", new Rule(){{
          add("id.value", 2L);
          add("id.seq", 200L);
          add("cities", has(2).of(City.class, "valid"));
      }});
   
      Fixture.of(RouteId.class).addTemplate("valid", new Rule(){{
        add("value", 1L);
        add("seq", 100L);
      }});
   
      Fixture.of(RoutePlanner.class).addTemplate("chainedRoutePlanner", new Rule(){{
          add("route.id.value", random(3L, 4L));
          add("route.id.seq", random(300L, 400L));
          add("route.cities", has(2).of(City.class, "valid"));
      }});
     
      Fixture.of(City.class).addTemplate("valid", new Rule(){{
          add("name", regex("\\w{8}"));
          add("neighborhoods", has(2).of(Neighborhood.class, "valid"));
      }});
     
      Fixture.of(Neighborhood.class).addTemplate("valid", new Rule(){{
        add("name", regex("\\w{12}"));
      }});
     
      Fixture.of(Attribute.class).addTemplate("valid", new Rule(){{
        add("value", regex("\\w{8}"));
      }});
     
      Fixture.of(Child.class).addTemplate("valid", new Rule(){{
        add("childAttribute", regex("\\w{16}"));
        add("parentAttribute", one(Attribute.class, "valid"));
      }});
     
      Fixture.of(Child.class).addTemplate("chained", new Rule(){{
          add("childAttribute", regex("\\w{16}"));
          add("parentAttribute.value", regex("\\w{8}"));
      }});       
  }
View Full Code Here

public class RouteTemplate implements TemplateLoader {

  @Override
  public void load() {
    Fixture.of(Route.class).addTemplate("routeWithDifferentCities", new Rule() {{
      add("id", one(RouteId.class, "valid"));
        add("cities", has(2).of(City.class, "saoPaulo", "rioDeJaneiro"));
    }});
   
    Fixture.of(City.class).addTemplate("saoPaulo", new Rule() {{
          add("name", "São Paulo");
          add("neighborhoods", has(2).of(Neighborhood.class, "valid"));
      }}).addTemplate("rioDeJaneiro", new Rule() {{
        add("name", "Rio de Janeiro");
          add("neighborhoods", has(2).of(Neighborhood.class, "valid"));
      }});
  }
View Full Code Here

public class XMLTransactionTemplate implements TemplateLoader {

  @Override
  public void load() {
    Fixture.of(XMLTransaction.class).addTemplate("validTransaction", new Rule(){{
      add("origin", "ORIGIN");
      add("date", instant("now"));
      add("hour", instant("now"));
    }});
  }
View Full Code Here

public class FixtureCircularTemplate implements TemplateLoader {

  @Override
  public void load() {
    Fixture.of(Order.class).addTemplate("valid", new Rule(){{
      add("id", random(Long.class, range(1L, 200L)));
      add("items", has(3).of(Item.class, "valid"));
      add("payment", one(Payment.class, "valid"));
    }});

    Fixture.of(Order.class).addTemplate("otherValid", new Rule(){{
      add("id", random(Long.class, range(1L, 200L)));
      add("items", has(3).of(Item.class, "valid").targetAttribute("order"));
      add("payment", one(Payment.class, "valid").targetAttribute("order"));
    }});
   
    Fixture.of(Item.class).addTemplate("valid", new Rule(){{
      add("productId", random(Integer.class, range(1L, 200L)));
    }});

    Fixture.of(Payment.class).addTemplate("valid", new Rule(){{
      add("id", random(Long.class, range(1L, 200L)));
    }});
  }
View Full Code Here

public class ClientTemplate implements TemplateLoader {

  @Override
  public void load() {
    Fixture.of(Client.class).addTemplate("valid", new Rule(){{
      add("id", random(Long.class, range(1L, 200L)));
      add("name", random("Anderson Parra", "Arthur Hirata"));
      add("nickname", random("nerd", "geek"));
      add("email", "${nickname}@gmail.com");
      add("birthday", instant("18 years ago"));
      add("birthdayAsString", instant("18 years ago").asString("dd/MM/yyyy"));
      add("address", one(Address.class, "valid"));
    }});
   
    Fixture.of(Client.class).addTemplate("valid-noaddress").inherits("valid", new Rule(){{
      add("address", null);
    }});
   
    Fixture.of(Address.class).addTemplate("valid", new Rule(){{
      add("id", random(Long.class, range(1L, 100L)));
      add("street", random("Paulista Avenue", "Ibirapuera Avenue"));
      add("city", one(City.class, "valid"));
      add("state", "${city}");
      add("country", "Brazil");
      add("zipCode", random("06608000", "17720000"));
    }});
   
    Fixture.of(Address.class).addTemplate("valid-augusta").inherits("valid", new Rule(){{
      add("street", "Augusta Street");
    }});
  }
View Full Code Here

TOP

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

Copyright © 2018 www.massapicom. 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.