@Test public void testGetNumberOfPersons() throws Exception { mockStatic(DependencyManager.class); expect(DependencyManager.getInstance()).andReturn(dependencyManagerMock); expect(dependencyManagerMock.getMyService()).andReturn(myServiceMock); Set<Person> persons = new HashSet<Person>(); persons.add(new Person("Johan", "Haleby", "MockStreet")); persons.add(new Person("Jan", "Kronquist", "MockStreet2")); expect(myServiceMock.getAllPersons()).andReturn(persons); replayAll(); int numberOfPersons = tested.getNumberOfPersons(); verifyAll(); assertEquals(2, numberOfPersons); }
public int getNumberOfPersons() { MyService myService = DependencyManager.getInstance().getMyService(); Set<Person> allPersons = myService.getAllPersons(); return allPersons.size(); }
MyServiceUser { public int getNumberOfPersons() { MyService myService = DependencyManager.getInstance().getMyService(); Set<Person> allPersons = myService.getAllPersons(); return allPersons.size(); } }
MyServiceUser { public int getNumberOfPersons() { MyService myService = DependencyManager.getInstance().getMyService(); Set<Person> allPersons = myService.getAllPersons(); return allPersons.size(); }  }
MyServiceUser { public int getNumberOfPersons() { MyService myService = DependencyManager.getInstance().getMyService(); Set<Person> allPersons = myService.getAllPersons(); return allPersons.size(); }  int getNumberOfPersons(); }
MyServiceUser { public int getNumberOfPersons() { MyService myService = DependencyManager.getInstance().getMyService(); Set<Person> allPersons = myService.getAllPersons(); return allPersons.size(); }  int getNumberOfPersons();  }