@Test public void shouldNotInsertDuplicatePeriodName() throws Exception { ProcessingSchedule schedule2 = make(a(defaultProcessingSchedule, with(code, "XXX"))); scheduleMapper.insert(schedule2); ProcessingPeriod period1 = make(a(defaultProcessingPeriod, with(scheduleId, schedule.getId()), with(name, "Month1"))); ProcessingPeriod period2 = make(a(defaultProcessingPeriod, with(scheduleId, schedule2.getId()), with(name, "Month1"))); ProcessingPeriod period3 = make(a(defaultProcessingPeriod, with(scheduleId, schedule2.getId()), with(name, "Month1"))); expectedException.expect(DuplicateKeyException.class); expectedException.expectMessage("duplicate key value violates unique constraint"); mapper.insert(period1); mapper.insert(period2); mapper.insert(period3); }
@Before public void setUp() throws Exception { schedule = make(a(defaultProcessingSchedule)); scheduleMapper.insert(schedule); }