Merge pull request #4682 from priyeshmashelkar/master
BAEL-1907 Moved code from spring-boot to testing-modules/mockito
This commit is contained in:
commit
cab2e3593d
|
@ -46,6 +46,38 @@
|
|||
<version>${hamcrest.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
<version>LATEST</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>LATEST</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.persistence</groupId>
|
||||
<artifactId>javax.persistence</artifactId>
|
||||
<version>2.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-jpa</artifactId>
|
||||
<version>LATEST</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -67,7 +99,6 @@
|
|||
<!-- testing -->
|
||||
<powermock.version>1.7.0</powermock.version>
|
||||
<hamcrest.version>2.0.0.0</hamcrest.version>
|
||||
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,49 @@
|
|||
package org.baeldung.mockito.repository;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "users")
|
||||
public class User {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Integer id;
|
||||
private String name;
|
||||
private Integer status;
|
||||
|
||||
public User() {
|
||||
}
|
||||
|
||||
public User(String name, Integer status) {
|
||||
this.name = name;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package org.baeldung.mockito.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository("userRepository")
|
||||
public interface UserRepository extends JpaRepository<User, Integer> {
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package org.baeldung;
|
||||
package org.baeldung.mockito;
|
||||
|
||||
import org.baeldung.repository.UserRepository;
|
||||
import org.baeldung.mockito.repository.UserRepository;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -9,7 +9,7 @@ import org.mockito.Mockito;
|
|||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class MockAnnotationTest {
|
||||
public class MockAnnotationUnitTest {
|
||||
|
||||
@Mock
|
||||
UserRepository mockRepository;
|
||||
|
@ -28,6 +28,6 @@ public class MockAnnotationTest {
|
|||
Mockito.when(localMockRepository.count()).thenReturn(111L);
|
||||
long userCount = localMockRepository.count();
|
||||
Assert.assertEquals(111L, userCount);
|
||||
Mockito.verify(localMockRepository).count();
|
||||
Mockito.verify(localMockRepository).count();
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package org.baeldung;
|
||||
package org.baeldung.mockito;
|
||||
|
||||
import org.baeldung.repository.UserRepository;
|
||||
import org.baeldung.mockito.repository.UserRepository;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -10,7 +10,6 @@ import org.springframework.boot.test.mock.mockito.MockBean;
|
|||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
public class MockBeanAnnotationIntegrationTest {
|
||||
|
Loading…
Reference in New Issue