Package org.apache.crunch.test

Examples of org.apache.crunch.test.Person


    assertEquals(record, detachedRecord);
    assertNotSame(record, detachedRecord);
  }

  private Person createPerson() {
    Person person = new Person();
    person.name = "name value";
    person.age = 42;
    person.siblingnames = Lists.<CharSequence> newArrayList();
    return person;
  }
View Full Code Here


  @Test
  public void testGetDetachedValue_SpecificAvroType() {
    AvroType<Person> specificType = Avros.specifics(Person.class);
    specificType.initialize(new Configuration());
    Person person = createPerson();
    Person detachedPerson = specificType.getDetachedValue(person);
    assertEquals(person, detachedPerson);
    assertNotSame(person, detachedPerson);
  }
View Full Code Here

  }

  @Test(expected = IllegalStateException.class)
  public void testGetDetachedValue_NotInitialized() {
    AvroType<Person> specificType = Avros.specifics(Person.class);
    Person person = createPerson();
    specificType.getDetachedValue(person);
  }
View Full Code Here

    assertNotSame(rp, detached);
  }

  @Test
  public void testGetDetachedValue_Pair() {
    Person person = createPerson();
    AvroType<Pair<Integer, Person>> pairType = Avros.pairs(Avros.ints(),
        Avros.records(Person.class));
    pairType.initialize(new Configuration());

    Pair<Integer, Person> inputPair = Pair.of(1, person);
View Full Code Here

    assertNotSame(inputPair.second(), detachedPair.second());
  }

  @Test
  public void testGetDetachedValue_Collection() {
    Person person = createPerson();
    List<Person> personList = Lists.newArrayList(person);

    AvroType<Collection<Person>> collectionType = Avros.collections(Avros.records(Person.class));
    collectionType.initialize(new Configuration());

    Collection<Person> detachedCollection = collectionType.getDetachedValue(personList);

    assertEquals(personList, detachedCollection);
    Person detachedPerson = detachedCollection.iterator().next();

    assertNotSame(person, detachedPerson);
  }
View Full Code Here

  }

  @Test
  public void testGetDetachedValue_Map() {
    String key = "key";
    Person value = createPerson();

    Map<String, Person> stringPersonMap = Maps.newHashMap();
    stringPersonMap.put(key, value);

    AvroType<Map<String, Person>> mapType = Avros.maps(Avros.records(Person.class));
View Full Code Here

    assertNotSame(value, detachedMap.get(key));
  }

  @Test
  public void testGetDetachedValue_TupleN() {
    Person person = createPerson();
    AvroType<TupleN> ptype = Avros.tuples(Avros.records(Person.class));
    ptype.initialize(new Configuration());
    TupleN tuple = new TupleN(person);
    TupleN detachedTuple = ptype.getDetachedValue(tuple);
View Full Code Here

@RunWith(AvroChildClassloaderTestRunner.class)
public class AvroSpecificDeepCopierClassloaderTest {

  @Test
  public void testDeepCopyWithinChildClassloader() {
    Person person = new Person();
    person.name = "John Doe";
    person.age = 42;
    person.siblingnames = Lists.newArrayList();

    Person deepCopyPerson = new AvroSpecificDeepCopier<Person>(Person.class, Person.SCHEMA$)
        .deepCopy(person);

    assertEquals(person, deepCopyPerson);
    assertNotSame(person, deepCopyPerson);
  }
View Full Code Here

    assertEquals(pair, doubleMappedPair);
  }

  @Test
  public void testPairs_Specific() {
    Person personA = new Person();
    Person personB = new Person();

    personA.age = 1;
    personA.name = "A";
    personA.siblingnames = Collections.<CharSequence> emptyList();
View Full Code Here

public class AvroDeepCopierTest {
 
  @Test
  public void testDeepCopySpecific() {
    Person person = new Person();
    person.name = "John Doe";
    person.age = 42;
    person.siblingnames = Lists.<CharSequence> newArrayList();

    Person deepCopyPerson = new AvroSpecificDeepCopier<Person>(Person.class, Person.SCHEMA$)
        .deepCopy(person);

    assertEquals(person, deepCopyPerson);
    assertNotSame(person, deepCopyPerson);
  }
View Full Code Here

TOP

Related Classes of org.apache.crunch.test.Person

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.