Package org.apache.crunch.test

Examples of org.apache.crunch.test.Person


  }

  @Test
  public void testMemPipelineWithSpecificRecord() {

    Person writeRecord = createSpecificRecord();

    final PCollection<Person> writeCollection = MemPipeline.typedCollectionOf(
                                                  Avros.specifics(Person.class),
                                                  writeRecord);

    writeCollection.write(To.avroFile(avroFile.getAbsolutePath()));

    PCollection<Person> readCollection = MemPipeline.getInstance().read(
        At.avroFile(avroFile.getAbsolutePath(), Avros.records(Person.class)));

    Person readRecord = readCollection.materialize().iterator().next();

    assertEquals(writeRecord, readRecord);
  }
View Full Code Here


    assertEquals(writeRecord, readRecord);
  }

  private Person createSpecificRecord() {
    List<CharSequence> siblingnames = Lists.newArrayList();
    return new Person("John", 41, siblingnames);
  }
View Full Code Here

  static class StringToStringWrapperPersonPairMapFn extends MapFn<String, Pair<StringWrapper, Person>> {

    @Override
    public Pair<StringWrapper, Person> map(String input) {
      Person person = new Person();
      person.name = input;
      person.age = 42;
      person.siblingnames = Lists.<CharSequence> newArrayList();
      return Pair.of(new StringWrapper(input), person);
    }
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.SCHEMA$).deepCopy(person);

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

    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

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.