Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // MyBean.java
- // this needs to be in java as it is playing with spring-data-neo4j
- package com.me;
- public class MyBean {
- @Autowired
- def someNeo4jBeanThatCannotBeTestedByItself
- String readFromDb(yeah) {
- someNeo4jBeanThatCannotBeTestedByItself.doSomething(yeah)
- return "Hello from DB";
- }
- }
- package com.me;
- public class MyBeanTest {
- def myBean
- def startUp(){
- myBean.someNeo4jBeanThatCannotBeTestedByItself = mockFor(SomeNeo4jBeanThatCannotBeTestedByItself)
- }
- def tearDown(){
- }
- def testReadFromDb() {
- myBean.someNeo4jBeanThatCannotBeTestedByItself.demand.doSomething = { String yeah -> 'yeahyeah' }
- def resp = myBean.doSomething('test')
- assertEquals 'Should respond with proper text', "Hello from DB", resp
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement