@Test public void addressEntityShouldBeFoundedByName() { addressDao.addAddress( new Address( "testAddress1", Arrays.asList(new Phone("testPhone"), new Phone("testPhone2")))); addressDao.addAddress( new Address( "testAddress2", Arrays.asList(new Phone("testPhone"), new Phone("testPhone2")))); addressDao.addAddress( new Address( "testAddress3", Arrays.asList(new Phone("testPhone"), new Phone("testPhone2")))); Assert.assertEquals(3, addressDao.getAddressesByName("Address").size()); Assert.assertEquals(0, addressDao.getAddressesByName("bagSearchString").size()); }
@Test public void twoPhonesShouldBeSavedWithOneAddress() { addressDao.addAddress( new Address("testAddress", Arrays.asList(new Phone("testPhone"), new Phone("testPhone2")))); DbHelper.checkDbByQuery( "SELECT count(*) = 1 AS DATA FROM addresses WHERE address = 'testAddress'"); DbHelper.checkDbByQuery("SELECT count(*) = 2 AS DATA FROM phones"); }