Merge pull request #334 from eugenp/inject-mocks-cleanup

Inject mocks cleanup
This commit is contained in:
David Morley 2016-01-19 06:14:50 -06:00
commit 699c3d5b3f
6 changed files with 41 additions and 42 deletions

View File

@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.baeldung</groupId>
<groupId>com.baeldung</groupId>
<artifactId>mockito-mocks-spring-beans</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
@ -51,5 +51,4 @@
</plugins>
</build>
</project>

View File

@ -1,4 +1,4 @@
package org.baeldung;
package com.baeldung;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

View File

@ -1,10 +1,10 @@
package org.baeldung;
package com.baeldung;
import org.springframework.stereotype.Service;
@Service
public class NameService {
public String getUserName(String id) {
return "Baeldung";
return "Real user name";
}
}

View File

@ -1,4 +1,4 @@
package org.baeldung;
package com.baeldung;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

View File

@ -1,4 +1,4 @@
package org.baeldung;
package com.baeldung;
import org.mockito.Mockito;
import org.springframework.context.annotation.Bean;

View File

@ -1,4 +1,4 @@
package org.baeldung;
package com.baeldung;
import org.junit.Assert;
import org.junit.Test;
@ -22,10 +22,10 @@ public class UserServiceTest {
@Test
public void whenUserIdIsProvided_thenRetrievedNameIsCorrect() {
Mockito.when(nameService.getUserName("SomeId")).thenReturn("Baeldung");
Mockito.when(nameService.getUserName("SomeId")).thenReturn("Mock user name");
String testName = userService.getUserName("SomeId");
Assert.assertEquals("Baeldung", testName);
Assert.assertEquals("Mock user name", testName);
}
}