@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]); } }
@Test public void testPersistEntity_EntityWithArrayOfMixedType() { System.out.println("\nTestPersistenceManager.testPersistEntity_EntityWithArrayOfMixedType()"); System.out.println( "----------------------------------------------------------------------------"); Filter filter = new Filter(); Object[] objects = new Object[] {"Hi", new Integer(1)}; filter.setMixedArray(objects); persistenceManager.persistEntity(filter); List<Filter> filters = persistenceManager.getEntities(Filter.class); assertNotNull(filters); assertEquals(1, filters.size()); Filter retrievedFilter = filters.get(0); assertNotNull(retrievedFilter.getId()); assertNull(retrievedFilter.getMixedArray()); assertNotSame(filter.getMixedArray(), retrievedFilter.getMixedArray()); }
@Test public void testPersistEntity_EntityWithCollectionOfMixedType() { System.out.println( "\nTestPersistenceManager.testPersistEntity_EntityWithCollectionOfMixedType()"); System.out.println( "----------------------------------------------------------------------------"); Filter filter = new Filter(); 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()); assertNull(retrievedFilter.getMixedValues()); assertNotSame(filter.getMixedValues(), retrievedFilter.getMixedValues()); }