Search in sources :

Example 21 with Employee

use of org.apache.gora.examples.generated.Employee in project gora by apache.

the class DataStoreTestUtil method testGetEmployeeNonExisting.

public static void testGetEmployeeNonExisting(DataStore<String, Employee> dataStore) throws Exception {
    Employee employee = dataStore.get("_NON_EXISTING_SSN_FOR_EMPLOYEE_");
    assertNull(employee);
}
Also used : Employee(org.apache.gora.examples.generated.Employee)

Example 22 with Employee

use of org.apache.gora.examples.generated.Employee in project gora by apache.

the class DataStoreTestUtil method testGetEmployee3UnionField.

public static void testGetEmployee3UnionField(DataStore<String, Employee> dataStore) throws Exception {
    Employee employee = DataStoreTestUtil.createEmployee();
    employee.setBoss(new Utf8("Real boss"));
    String ssn = employee.getSsn().toString();
    dataStore.put(ssn, employee);
    dataStore.flush();
    Employee after = dataStore.get(ssn, AvroUtils.getSchemaFieldNames(Employee.SCHEMA$));
    assertEqualEmployeeObjects(employee, after);
    assertEquals("Real boss", after.getBoss().toString());
}
Also used : Employee(org.apache.gora.examples.generated.Employee) Utf8(org.apache.avro.util.Utf8)

Example 23 with Employee

use of org.apache.gora.examples.generated.Employee in project gora by apache.

the class DataStoreTestUtil method testGetEmployeeNested.

public static void testGetEmployeeNested(DataStore<String, Employee> dataStore) throws Exception {
    Employee employee = DataStoreTestUtil.createEmployee();
    WebPage webpage = new BeanFactoryImpl<>(String.class, WebPage.class).newPersistent();
    webpage.setUrl(new Utf8("url.."));
    webpage.setContent(ByteBuffer.wrap("test content".getBytes(Charset.defaultCharset())));
    webpage.setParsedContent(new ArrayList<CharSequence>());
    Metadata metadata = new BeanFactoryImpl<>(String.class, Metadata.class).newPersistent();
    webpage.setMetadata(metadata);
    employee.setWebpage(webpage);
    String ssn = employee.getSsn().toString();
    dataStore.put(ssn, employee);
    dataStore.flush();
    Employee after = dataStore.get(ssn, AvroUtils.getSchemaFieldNames(Employee.SCHEMA$));
    assertEqualEmployeeObjects(employee, after);
    assertEqualWebPageObjects(webpage, after.getWebpage());
}
Also used : WebPage(org.apache.gora.examples.generated.WebPage) Employee(org.apache.gora.examples.generated.Employee) Metadata(org.apache.gora.examples.generated.Metadata) Utf8(org.apache.avro.util.Utf8)

Aggregations

Employee (org.apache.gora.examples.generated.Employee)23 Utf8 (org.apache.avro.util.Utf8)11 Test (org.junit.Test)7 WebPage (org.apache.gora.examples.generated.WebPage)5 Metadata (org.apache.gora.examples.generated.Metadata)2 Configuration (org.apache.hadoop.conf.Configuration)2 HashMap (java.util.HashMap)1 GoraInfinispanTestDriver (org.apache.gora.infinispan.GoraInfinispanTestDriver)1 Before (org.junit.Before)1