Package org.apache.gora.examples.generated

Examples of org.apache.gora.examples.generated.Employee


    //more tests for clone are in TestPersistentDatumReader
    @SuppressWarnings("unchecked")
    MemStore<String, Employee> store = DataStoreFactory.getDataStore(
        MemStore.class, String.class, Employee.class);

    Employee employee = DataStoreTestUtil.createEmployee(store);
   
    Assert.assertEquals(employee, employee.clone());
  }
View Full Code Here


    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);
View Full Code Here

    dataStore.createSchema();
    long ssn = 1234567890L;
    long now = System.currentTimeMillis();

    for (int i = 0; i < 5; i++) {
      Employee employee = dataStore.newPersistent();
      employee.setName(new Utf8("John Doe " + i));
      employee.setDateOfBirth(now - 20L *  YEAR_IN_MS);
      employee.setSalary(100000);
      employee.setSsn(new Utf8(Long.toString(ssn + i)));
      dataStore.put(employee.getSsn().toString(), employee);
    }

    dataStore.flush();

    for (int i = 0; i < 1; i++) {
      Employee employee = dataStore.newPersistent();
      employee.setName(new Utf8("John Doe " + (i + 5)));
      employee.setDateOfBirth(now - 18L *  YEAR_IN_MS);
      employee.setSalary(120000);
      employee.setSsn(new Utf8(Long.toString(ssn + i)));
      dataStore.put(employee.getSsn().toString(), employee);
    }

    dataStore.flush();

    for (int i = 0; i < 1; i++) {
      String key = Long.toString(ssn + i);
      Employee employee = dataStore.get(key);
      Assert.assertEquals(now - 18L * YEAR_IN_MS, employee.getDateOfBirth());
      Assert.assertEquals("John Doe " + (i + 5), employee.getName().toString());
      Assert.assertEquals(120000, employee.getSalary());
    }
  }
View Full Code Here

  }

  @Test
  public void testPut() throws IOException {
    log.info("test method: testPut");
    Employee employee = DataStoreTestUtil.testPutEmployee(employeeStore);
    assertPut(employee);
  }
View Full Code Here

  public void testSerdeEmployee() throws Exception {

    MemStore<String, Employee> store = DataStoreFactory.getDataStore(
        MemStore.class, String.class, Employee.class);

    Employee employee = DataStoreTestUtil.createEmployee(store);

    TestIOUtils.testSerializeDeserialize(employee);
  }
View Full Code Here

    TestIOUtils.testSerializeDeserialize(employee);
  }

  @Test
  public void testSerdeEmployeeOneField() throws Exception {
    Employee employee = new Employee();
    employee.setSsn(new Utf8("11111"));

    TestIOUtils.testSerializeDeserialize(employee);
  }
View Full Code Here

    TestIOUtils.testSerializeDeserialize(employee);
  }

  @Test
  public void testSerdeEmployeeTwoFields() throws Exception {
    Employee employee = new Employee();
    employee.setSsn(new Utf8("11111"));
    employee.setSalary(100);

    TestIOUtils.testSerializeDeserialize(employee);
  }
View Full Code Here

  }

  public static <K> Employee createEmployee(
      DataStore<K, Employee> dataStore) throws IOException {

    Employee employee = dataStore.newPersistent();
    employee.setName(new Utf8("Random Joe"));
    employee.setDateOfBirth( System.currentTimeMillis() - 20L *  YEAR_IN_MS );
    employee.setSalary(100000);
    employee.setSsn(new Utf8("101010101010"));
    return employee;
  }
View Full Code Here

  }

  public static void testGetEmployee(DataStore<String, Employee> dataStore)
    throws IOException {
    dataStore.createSchema();
    Employee employee = DataStoreTestUtil.createEmployee(dataStore);
    String ssn = employee.getSsn().toString();
    dataStore.put(ssn, employee);
    dataStore.flush();

    Employee after = dataStore.get(ssn, Employee._ALL_FIELDS);

    Assert.assertEquals(employee, after);
  }
View Full Code Here

    Assert.assertEquals(employee, after);
  }

  public static void testGetEmployeeNonExisting(DataStore<String, Employee> dataStore)
    throws IOException {
    Employee employee = dataStore.get("_NON_EXISTING_SSN_FOR_EMPLOYEE_");
    Assert.assertNull(employee);
  }
View Full Code Here

TOP

Related Classes of org.apache.gora.examples.generated.Employee

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.