Package org.apache.gora.examples.generated

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


  }

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


  }

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

    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, Exception {
    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, Exception {
    Employee employee = dataStore.get("_NON_EXISTING_SSN_FOR_EMPLOYEE_");
    Assert.assertNull(employee);
  }
View Full Code Here

    Assert.assertNull(employee);
  }

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

    String[] fields = employee.getFields();
    for(Set<String> subset : StringUtils.powerset(fields)) {
      if(subset.isEmpty())
        continue;
      Employee after = dataStore.get(ssn, subset.toArray(new String[subset.size()]));
      Employee expected = new Employee();
      for(String field:subset) {
        int index = expected.getFieldIndex(field);
        expected.put(index, employee.get(index));
      }

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

  }

  public static Employee testPutEmployee(DataStore<String, Employee> dataStore)
  throws IOException, Exception {
    dataStore.createSchema();
    Employee employee = DataStoreTestUtil.createEmployee(dataStore);
    return employee;
  }
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

    WebPage page = new WebPage();
    for(int i=0; i<WebPage._ALL_FIELDS.length; i++) {
      int index = page.getFieldIndex(WebPage._ALL_FIELDS[i]);
      Assert.assertEquals(i, index);
    }
    Employee employee = new Employee();
    for(int i=0; i<Employee._ALL_FIELDS.length; i++) {
      int index = employee.getFieldIndex(Employee._ALL_FIELDS[i]);
      Assert.assertEquals(i, index);
    }
  }
View Full Code Here

    //test clear new object
    page = new WebPage();
    page.clear();
   
    //test primitive fields
    Employee employee = new Employee();
    employee.clear();
  }
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.