コード例 #1
0
  @Test
  public void testPersistEntity_EntityWithArray() {

    System.out.println("\nTestPersistenceManager.testPersistEntity_EntityWithArray()");
    System.out.println("------------------------------------------------------------");
    Filter filter = new Filter();
    List<String> values = new ArrayList<String>();
    values.add("Value1");
    values.add("Value2");
    filter.setValues(values);

    String[] simpleArray = new String[] {"Kayal", "Vizhi"};
    filter.setSimpleArray(simpleArray);
    Tuple[] complexArray = new Tuple[] {new Tuple("a", "A"), new Tuple("b", "B")};
    filter.setComplexArray(complexArray);

    persistenceManager.persistEntity(filter);

    List<Filter> filters = persistenceManager.getEntities(Filter.class);
    assertNotNull(filters);
    assertEquals(1, filters.size());
    Filter retrievedFilter = filters.get(0);
    assertNotNull(retrievedFilter.getId());
    assertEquals(filter.getValues(), retrievedFilter.getValues());
    assertEquals(complexArray.length, retrievedFilter.getComplexArray().length);
    for (int i = 0; i < complexArray.length; i++) {
      assertEquals(complexArray[i], retrievedFilter.getComplexArray()[i]);
    }
  }
コード例 #2
0
  @Test
  public void testPersistEntity_EntityWithListOfSimpleType() {

    System.out.println("\nTestPersistenceManager.testPersistEntity_EntityWithListOfSimpleType()");
    System.out.println("------------------------------------------------------------------------");
    Filter filter = new Filter();
    List<String> values = new ArrayList<String>();
    values.add("Value1");
    values.add("Value2");
    filter.setValues(values);

    List<Object> mixedValues = new ArrayList<Object>();
    mixedValues.add("Hi");
    mixedValues.add(0);
    filter.setMixedValues(mixedValues);
    persistenceManager.persistEntity(filter);

    List<Filter> filters = persistenceManager.getEntities(Filter.class);
    assertNotNull(filters);
    assertEquals(1, filters.size());
    Filter retrievedFilter = filters.get(0);
    assertNotNull(retrievedFilter.getId());
    assertEquals(filter.getValues(), retrievedFilter.getValues());
  }