@Test(expected = ConcurrentModificationException.class) public void verify_newObjectAlreadySaved() throws Exception { // given Organization o = new Organization(); o.setKey(1); Organization t = new Organization(); t.setKey(0); // when VersionAndKeyValidator.verify(o, t, 0); }
@Test public void verify() throws Exception { // given Organization o = new Organization(); o.setKey(0); Organization t = new Organization(); t.setKey(0); // when VersionAndKeyValidator.verify(o, t, 0); }
@Test(expected = SaaSSystemException.class) public void verify_differentObjects() throws Exception { // given Organization o = new Organization(); o.setKey(1); Organization t = new Organization(); t.setKey(2); // when VersionAndKeyValidator.verify(o, t, 0); }
@Test public void verify_wrongTemplateVersionInErrorMessage() throws Exception { // given Organization o = new Organization(); o.setKey(1); Organization t = new Organization(); t.setKey(0); // when try { VersionAndKeyValidator.verify(o, t, 1); } catch (ConcurrentModificationException e) { // then String versionInMessage = e.getMessage().substring(e.getMessage().length() - 1, e.getMessage().length()); assertEquals("1", versionInMessage); } }