Advertisement
raphaelom

Untitled

Nov 18th, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 0.79 KB | None | 0 0
  1. // MyBean.java
  2. // this needs to be in java as it is playing with spring-data-neo4j
  3. package com.me;
  4. public class MyBean {
  5.     @Autowired
  6.     def someNeo4jBeanThatCannotBeTestedByItself
  7.  
  8.  
  9.     String readFromDb(yeah) {
  10.         someNeo4jBeanThatCannotBeTestedByItself.doSomething(yeah)
  11.         return "Hello from DB";
  12.     }
  13. }
  14.  
  15. package com.me;
  16. public class MyBeanTest {
  17.     def myBean
  18.  
  19.     def startUp(){
  20.     myBean.someNeo4jBeanThatCannotBeTestedByItself = mockFor(SomeNeo4jBeanThatCannotBeTestedByItself)
  21.     }
  22.     def tearDown(){
  23.     }  
  24.    
  25.     def testReadFromDb() {
  26.     myBean.someNeo4jBeanThatCannotBeTestedByItself.demand.doSomething = { String yeah -> 'yeahyeah' }
  27.     def resp = myBean.doSomething('test')
  28.         assertEquals 'Should respond with proper text', "Hello from DB", resp
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement