Created
December 14, 2016 14:48
-
-
Save frant-hartm/eb54c6ca346f4c5cee2636a1bbead404 to your computer and use it in GitHub Desktop.
SDN 4.2 issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(SpringJUnit4ClassRunner.class) | |
@ContextConfiguration(classes = {GalaxyContext.class, MyConfig.class}) | |
@Transactional | |
public class MyTest { | |
@Autowired | |
WorldRepository worldRepository; | |
@Test(expected = DataIntegrityViolationException.class) | |
public void shouldTrowRollbackException() throws Exception { | |
worldRepository.save(new World("Tatooine", 0)); | |
worldRepository.save(new World("Tatooine", 0)); | |
} | |
@Configuration | |
public static class MyConfig { | |
@Bean | |
public SessionFactory sessionFactory() { | |
org.neo4j.ogm.config.Configuration configuration = new org.neo4j.ogm.config.Configuration(); | |
configuration.driverConfiguration().setDriverClassName(EmbeddedDriver.class.getCanonicalName()); | |
return new SessionFactory(configuration, "org.springframework.data.neo4j.examples.galaxy.domain"); | |
} | |
@Bean | |
public Neo4jOperations neo4jOperations() { | |
Neo4jTemplate neo4jTemplate = new Neo4jTemplate(sessionFactory()); | |
Map<String, Object> map = Collections.emptyMap(); | |
neo4jTemplate.query("CREATE CONSTRAINT ON (w:World) ASSERT w.name IS UNIQUE", map); | |
return neo4jTemplate; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment