Skip to content

Commit fa39775

Browse files
dharrigandaschl
authored andcommitted
DATACOUCH-37 - Refactor Deprecated JUnit Asserts.
Removed deprecated methods and changed to Hamcrest. -=david=-
1 parent 46566b9 commit fa39775

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

src/main/java/org/springframework/data/couchbase/monitor/AbstractMonitor.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected RestTemplate getTemplate() {
5050
}
5151

5252
protected String randomAvailableHostname() {
53-
List<SocketAddress> available = (ArrayList) client.getAvailableServers();
53+
List<SocketAddress> available = (ArrayList<SocketAddress>) client.getAvailableServers();
5454
Collections.shuffle(available);
5555
return ((InetSocketAddress) available.get(0)).getHostName();
5656
}
@@ -60,15 +60,12 @@ protected String randomAvailableHostname() {
6060
*
6161
* @return stats for each node
6262
*/
63-
protected Map<SocketAddress,Map<String,String>> getStats() {
63+
protected Map<SocketAddress, Map<String, String>> getStats() {
6464
return client.getStats();
6565
}
6666

6767
/**
6868
* Returns stats for an individual node.
69-
*
70-
* @param node
71-
* @return
7269
*/
7370
protected Map<String, String> getStats(SocketAddress node) {
7471
return getStats().get(node);

src/test/java/org/springframework/data/couchbase/core/mapping/MappingCouchbaseConverterTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ static class MapEntity extends BaseEntity {
440440
private Map<String, Boolean> attr1;
441441
private Map<Integer, String> attr2;
442442
private Map<String, Map<String, String>> attr3;
443-
public MapEntity(Map attr0, Map attr1, Map attr2, Map attr3) {
443+
public MapEntity(Map<String, String> attr0, Map<String, Boolean> attr1, Map<Integer, String> attr2, Map<String, Map<String, String>> attr3) {
444444
this.attr0 = attr0;
445445
this.attr1 = attr1;
446446
this.attr2 = attr2;

src/test/java/org/springframework/data/couchbase/monitor/ClientInfoTests.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
import org.springframework.test.context.ContextConfiguration;
2626
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
2727

28-
import static junit.framework.Assert.assertNotNull;
28+
import static org.hamcrest.MatcherAssert.assertThat;
29+
import static org.hamcrest.Matchers.isEmptyString;
30+
import static org.hamcrest.Matchers.notNullValue;
31+
import static org.hamcrest.core.IsNot.not;
2932
import static org.junit.Assert.assertFalse;
3033

3134
/**
@@ -51,8 +54,7 @@ public void setup() throws Exception {
5154
@Test
5255
public void hostNames() {
5356
String hostnames = ci.getHostNames();
54-
assertNotNull(hostnames);
55-
assertFalse(hostnames.isEmpty());
57+
assertThat(hostnames, not(isEmptyString()));
5658
}
5759

5860
}

src/test/java/org/springframework/data/couchbase/monitor/ClusterInfoTests.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
import org.springframework.test.context.ContextConfiguration;
2626
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
2727

28-
import static junit.framework.Assert.assertTrue;
28+
import static org.hamcrest.MatcherAssert.assertThat;
29+
import static org.hamcrest.Matchers.greaterThan;
2930

3031
/**
3132
* @author Michael Nitschinger
@@ -49,12 +50,12 @@ public void setup() throws Exception {
4950

5051
@Test
5152
public void totalRAMAssigned() {
52-
assertTrue(ci.getTotalRAMAssigned() > 0);
53+
assertThat(ci.getTotalRAMAssigned(), greaterThan(0L));
5354
}
5455

5556
@Test
5657
public void totalRAMUsed() {
57-
assertTrue(ci.getTotalRAMUsed() > 0);
58+
assertThat(ci.getTotalRAMUsed(), greaterThan(0L));
5859
}
5960

6061
}

0 commit comments

Comments
 (0)