Package org.apache.crunch.test

Examples of org.apache.crunch.test.Person


  }

  @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

public class AvroTableTypeTest {

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

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

    PCollection<Person> genericCollection = pipeline.read(At.avroFile(avroFile.getAbsolutePath(),
        Avros.records(Person.class)));

    List<Person> personList = Lists.newArrayList(genericCollection.materialize());

    Person expectedPerson = new Person();
    expectedPerson.name = "John Doe";
    expectedPerson.age = 42;

    List<CharSequence> siblingNames = Lists.newArrayList();
    siblingNames.add("Jimmy");
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

    pipeline.done();
  }

  private void createPersonAvroFile(File avroFile) throws IOException {

    Person person = new Person();
    person.age = 40;
    person.name = "Bob";
    List<CharSequence> siblingNames = Lists.newArrayList();
    siblingNames.add("Bob" + "1");
    siblingNames.add("Bob" + "2");
View Full Code Here

public class AvroGroupedTableTypeTest {

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

    Iterable<Person> inputPersonIterable = Lists.newArrayList(person);
View Full Code Here

    AvroFileReaderFactory<Person> genericReader = createFileReaderFactory(Avros.records(Person.class));
    Iterator<Person> recordIterator = genericReader.read(FileSystem.getLocal(new Configuration()), new Path(
        this.avroFile.getAbsolutePath()));

    Person expectedPerson = new Person();
    expectedPerson.age = 42;
    expectedPerson.name = "John Doe";
    List<CharSequence> siblingNames = Lists.newArrayList();
    siblingNames.add("Jimmy");
    siblingNames.add("Jane");
    expectedPerson.siblingnames = siblingNames;

    Person person = recordIterator.next();

    assertEquals(expectedPerson, person);
    assertFalse(recordIterator.hasNext());
  }
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.