@Test @DataSet(DATA_FILENAME_ONE_LESS) @ExpectedDataSet(DATA_FILENAME_NO_CHANGEDATE) public void testInsertItemAssoc() { ItemAssocVO<Integer, Integer> itemAssoc = null; try { itemAssoc = new ItemAssocVO<Integer, Integer>( 1, new ItemVO<Integer, Integer>(1, 2, 1), 1, 0.1d, new ItemVO<Integer, Integer>(1, 7, 1), 2, "def", 1, true); } catch (Exception e) { fail("caught exception: " + e); } assertTrue(itemAssoc.getId() == null); itemAssocDAO.insertItemAssoc(itemAssoc); assertThat(itemAssoc.getId(), is(not(1))); assertThat(itemAssoc.getId(), is(not(2))); assertThat(itemAssoc.getId(), is(not(3))); assertThat(itemAssoc.getId(), is(not(4))); assertThat(itemAssoc.getId(), is(not(5))); }
@Test @DataSet(DATA_FILENAME_ONE_LESS) public void testInsertItemAssocViewTypeNull() { ItemAssocVO<Integer, Integer> itemAssoc = null; try { itemAssoc = new ItemAssocVO<Integer, Integer>( 1, new ItemVO<Integer, Integer>(1, 2, 1), 1, 0.1d, new ItemVO<Integer, Integer>(1, 7, 1), 2, "def", null, true); } catch (Exception e) { fail("caught exception: " + e); } assertTrue(itemAssoc.getId() == null); try { itemAssocDAO.insertItemAssoc(itemAssoc); fail("exception should be thrown, since 'viewType' is missing"); } catch (Exception e) { assertTrue( "unexpected exception during insertion of item association: " + itemAssoc + ", " + e.getMessage(), e instanceof IllegalArgumentException); } }
@Test public void testLoadItemAssocByPrimaryKey() { ItemAssocVO<Integer, Integer> queryAssoc = new ItemAssocVO<Integer, Integer>( 1, new ItemVO<Integer, Integer>(1, 1, 1), 1, null, new ItemVO<Integer, Integer>(1, 2, 1), 1, "abc", 1, null); ItemAssocVO<Integer, Integer> resultAssoc = itemAssocDAO.loadItemAssocByUniqueKey(queryAssoc); ItemAssocVO<Integer, Integer> resultAssoc2 = itemAssocDAO.loadItemAssocByPrimaryKey(resultAssoc.getId()); assertEquals(resultAssoc, resultAssoc2); }