@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"); }
@Before public void beforeTests() { DbHelper.clearDb(); AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class); addressDao = ctx.getBean(AddressDao.class); }