Search in sources :

Example 6 with Employee

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

the class DataStoreTestBase method testPut.

@Test
public void testPut() throws Exception {
    log.info("test method: testPut");
    Employee employee = DataStoreTestUtil.testPutEmployee(employeeStore);
    assertPut(employee);
}
Also used : Employee(org.apache.gora.examples.generated.Employee) Test(org.junit.Test)

Example 7 with Employee

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

the class DataStoreTestUtil method testGetEmployee.

public static void testGetEmployee(DataStore<String, Employee> dataStore) throws Exception {
    dataStore.createSchema();
    Employee employee = DataStoreTestUtil.createEmployee();
    String ssn = employee.getSsn().toString();
    dataStore.put(ssn, employee);
    dataStore.flush();
    Employee after = dataStore.get(ssn, AvroUtils.getSchemaFieldNames(Employee.SCHEMA$));
    assertEqualEmployeeObjects(employee, after);
}
Also used : Employee(org.apache.gora.examples.generated.Employee)

Example 8 with Employee

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

the class DataStoreTestUtil method testPutEmployee.

public static Employee testPutEmployee(DataStore<String, Employee> dataStore) throws Exception {
    dataStore.createSchema();
    Employee employee = DataStoreTestUtil.createEmployee();
    return employee;
}
Also used : Employee(org.apache.gora.examples.generated.Employee)

Example 9 with Employee

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

the class DataStoreTestUtil method testGetEmployeeDoubleRecursive.

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

Example 10 with Employee

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

the class DataStoreTestUtil method testEmptyUpdateEmployee.

public static void testEmptyUpdateEmployee(DataStore<String, Employee> dataStore) throws Exception {
    dataStore.createSchema();
    long ssn = 1234567890L;
    String ssnStr = Long.toString(ssn);
    long now = System.currentTimeMillis();
    Employee employee = dataStore.newPersistent();
    employee.setName(new Utf8("John Doe"));
    employee.setDateOfBirth(now - 20L * YEAR_IN_MS);
    employee.setSalary(100000);
    employee.setSsn(new Utf8(ssnStr));
    dataStore.put(employee.getSsn().toString(), employee);
    dataStore.flush();
    employee = dataStore.get(ssnStr);
    dataStore.put(ssnStr, employee);
    dataStore.flush();
    employee = dataStore.newPersistent();
    dataStore.put(Long.toString(ssn + 1), employee);
    dataStore.flush();
    employee = dataStore.get(Long.toString(ssn + 1));
    assertNull(employee);
}
Also used : Employee(org.apache.gora.examples.generated.Employee) 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