Merge pull request #334 from eugenp/inject-mocks-cleanup
Inject mocks cleanup
This commit is contained in:
commit
699c3d5b3f
|
@ -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>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung;
|
||||
package com.baeldung;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
@ -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";
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung;
|
||||
package com.baeldung;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung;
|
||||
package com.baeldung;
|
||||
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.context.annotation.Bean;
|
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue