Versions update (#2234)
* Mockito refactor * Httpclient refactor * Refactor json-path * MongoDB Refactor
This commit is contained in:
committed by
GitHub
parent
1957750382
commit
9ad123a655
+4
-4
@@ -1,12 +1,12 @@
|
||||
package com.baeldung.powermockito.introduction;
|
||||
|
||||
public class CollaboratorForPartialMocking {
|
||||
class CollaboratorForPartialMocking {
|
||||
|
||||
public static String staticMethod() {
|
||||
static String staticMethod() {
|
||||
return "Hello Baeldung!";
|
||||
}
|
||||
|
||||
public final String finalMethod() {
|
||||
final String finalMethod() {
|
||||
return "Hello Baeldung!";
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class CollaboratorForPartialMocking {
|
||||
return "Hello Baeldung!";
|
||||
}
|
||||
|
||||
public String privateMethodCaller() {
|
||||
String privateMethodCaller() {
|
||||
return privateMethod() + " Welcome to the Java world.";
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package com.baeldung.powermockito.introduction;
|
||||
|
||||
public class CollaboratorWithFinalMethods {
|
||||
class CollaboratorWithFinalMethods {
|
||||
|
||||
public final String helloMethod() {
|
||||
final String helloMethod() {
|
||||
return "Hello World!";
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -1,16 +1,16 @@
|
||||
package com.baeldung.powermockito.introduction;
|
||||
|
||||
public class CollaboratorWithStaticMethods {
|
||||
class CollaboratorWithStaticMethods {
|
||||
|
||||
public static String firstMethod(String name) {
|
||||
static String firstMethod(String name) {
|
||||
return "Hello " + name + " !";
|
||||
}
|
||||
|
||||
public static String secondMethod() {
|
||||
static String secondMethod() {
|
||||
return "Hello no one!";
|
||||
}
|
||||
|
||||
public static String thirdMethod() {
|
||||
static String thirdMethod() {
|
||||
return "Hello no one again!";
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ public class MockitoAnnotationIntegrationTest {
|
||||
private List<String> mockedList;
|
||||
|
||||
@Spy
|
||||
List<String> spiedList = new ArrayList<String>();
|
||||
private List<String> spiedList = new ArrayList<>();
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
@@ -87,6 +87,7 @@ public class MockitoAnnotationIntegrationTest {
|
||||
}
|
||||
|
||||
@Captor
|
||||
private
|
||||
ArgumentCaptor<String> argCaptor;
|
||||
|
||||
@Test
|
||||
@@ -98,10 +99,10 @@ public class MockitoAnnotationIntegrationTest {
|
||||
}
|
||||
|
||||
@Mock
|
||||
Map<String, String> wordMap;
|
||||
private Map<String, String> wordMap;
|
||||
|
||||
@InjectMocks
|
||||
MyDictionary dic = new MyDictionary();
|
||||
private MyDictionary dic = new MyDictionary();
|
||||
|
||||
@Test
|
||||
public void whenUseInjectMocksAnnotation_thenCorrect() {
|
||||
|
||||
@@ -24,7 +24,7 @@ public class MockitoMockIntegrationTest {
|
||||
}
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
private ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void whenUsingSimpleMock_thenCorrect() {
|
||||
|
||||
@@ -3,19 +3,19 @@ package org.baeldung.mockito;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MyDictionary {
|
||||
class MyDictionary {
|
||||
|
||||
Map<String, String> wordMap;
|
||||
private Map<String, String> wordMap;
|
||||
|
||||
public MyDictionary() {
|
||||
wordMap = new HashMap<String, String>();
|
||||
MyDictionary() {
|
||||
wordMap = new HashMap<>();
|
||||
}
|
||||
|
||||
public void add(final String word, final String meaning) {
|
||||
wordMap.put(word, meaning);
|
||||
}
|
||||
|
||||
public String getMeaning(final String word) {
|
||||
String getMeaning(final String word) {
|
||||
return wordMap.get(word);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.baeldung.mockito;
|
||||
|
||||
import java.util.AbstractList;
|
||||
|
||||
public class MyList extends AbstractList<String> {
|
||||
class MyList extends AbstractList<String> {
|
||||
|
||||
@Override
|
||||
public String get(final int index) {
|
||||
|
||||
Reference in New Issue
Block a user