@Test(expected = DataIntegrityViolationException.class) public void addConnectionDuplicate() { Connection<TestFacebookApi> connection = connectionFactory.createConnection(new AccessGrant("123456789", null, "987654321", 3600L)); connectionRepository.addConnection(connection); connectionRepository.addConnection(connection); }
@Test public void addConnection() { Connection<TestFacebookApi> connection = connectionFactory.createConnection(new AccessGrant("123456789", null, "987654321", 3600L)); connectionRepository.addConnection(connection); Connection<TestFacebookApi> restoredConnection = connectionRepository.getPrimaryConnection(TestFacebookApi.class); assertEquals(connection, restoredConnection); assertNewConnection(restoredConnection); }