You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2020/11/19 17:04:16 UTC
[camel] branch master updated: Simplified assertions (#4634)
This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new 6b334e2 Simplified assertions (#4634)
6b334e2 is described below
commit 6b334e286e8212efa4679235e93290ab6ce6c0bf
Author: Otavio Rodolfo Piske <or...@users.noreply.github.com>
AuthorDate: Thu Nov 19 17:57:25 2020 +0100
Simplified assertions (#4634)
Components: camel-fhir, camel-ftp, camel-google-calendar,
camel-google-drive, camel-google-mail, camel-google-pubsub
---
.../java/org/apache/camel/component/fhir/FhirTransactionIT.java | 5 +++--
.../camel/component/file/remote/FtpConsumerWithCharsetTest.java | 3 ++-
.../component/file/remote/FtpPollingConsumerIdleMessageTest.java | 6 +++---
.../camel/component/file/remote/FtpProducerFileWithCharsetTest.java | 3 ++-
.../google/calendar/CalendarCalendarListIntegrationTest.java | 3 ++-
.../component/google/calendar/CalendarCalendarsIntegrationTest.java | 6 +++---
.../camel/component/google/drive/DriveFilesIntegrationTest.java | 4 ++--
.../component/google/mail/GmailUsersLabelsIntegrationTest.java | 6 +++---
.../camel/component/google/pubsub/integration/BodyTypesTest.java | 5 +++--
9 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/FhirTransactionIT.java b/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/FhirTransactionIT.java
index 8596c90..7969e24 100644
--- a/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/FhirTransactionIT.java
+++ b/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/FhirTransactionIT.java
@@ -34,6 +34,7 @@ import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -83,7 +84,7 @@ public class FhirTransactionIT extends AbstractFhirTestSupport {
assertNotNull(result, "withResources result");
LOG.debug("withResources: " + result);
- assertTrue(result.size() == 2);
+ assertEquals(2, result.size());
}
@Test
@@ -101,7 +102,7 @@ public class FhirTransactionIT extends AbstractFhirTestSupport {
assertNotNull(result, "withResources result");
LOG.debug("withResources: " + result);
- assertTrue(result.size() == 2);
+ assertEquals(2, result.size());
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerWithCharsetTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerWithCharsetTest.java
index 301e3e1..4f6fc6c 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerWithCharsetTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerWithCharsetTest.java
@@ -32,6 +32,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -73,7 +74,7 @@ public class FtpConsumerWithCharsetTest extends FtpServerTestSupport {
byte[] buffer = new byte[100];
int len = fis.read(buffer);
- assertTrue(len != -1, "Should read data: " + len);
+ assertNotEquals(-1, len, "Should read data: " + len);
byte[] data = new byte[len];
System.arraycopy(buffer, 0, data, 0, len);
fis.close();
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollingConsumerIdleMessageTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollingConsumerIdleMessageTest.java
index 72697bf..09c06b8 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollingConsumerIdleMessageTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollingConsumerIdleMessageTest.java
@@ -23,7 +23,7 @@ import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Test to verify that the polling consumer delivers an empty Exchange when the sendEmptyMessageWhenIdle property is set
@@ -37,8 +37,8 @@ public class FtpPollingConsumerIdleMessageTest extends FtpServerTestSupport {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMinimumMessageCount(2);
assertMockEndpointsSatisfied();
- assertTrue(mock.getExchanges().get(0).getIn().getBody() == null);
- assertTrue(mock.getExchanges().get(1).getIn().getBody() == null);
+ assertNull(mock.getExchanges().get(0).getIn().getBody());
+ assertNull(mock.getExchanges().get(1).getIn().getBody());
}
@BeforeEach
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithCharsetTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithCharsetTest.java
index b6f6d2f..957db84 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithCharsetTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithCharsetTest.java
@@ -29,6 +29,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class FtpProducerFileWithCharsetTest extends FtpServerTestSupport {
@@ -73,7 +74,7 @@ public class FtpProducerFileWithCharsetTest extends FtpServerTestSupport {
byte[] buffer = new byte[100];
int len = fis.read(buffer);
- assertTrue(len != -1, "Should read data: " + len);
+ assertNotEquals(-1, len, "Should read data: " + len);
byte[] data = new byte[len];
System.arraycopy(buffer, 0, data, 0, len);
fis.close();
diff --git a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarCalendarListIntegrationTest.java b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarCalendarListIntegrationTest.java
index f98b55a..c7feda8 100644
--- a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarCalendarListIntegrationTest.java
+++ b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarCalendarListIntegrationTest.java
@@ -24,6 +24,7 @@ import org.apache.camel.component.google.calendar.internal.CalendarCalendarListA
import org.apache.camel.component.google.calendar.internal.GoogleCalendarApiCollection;
import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
@@ -40,7 +41,7 @@ public class CalendarCalendarListIntegrationTest extends AbstractGoogleCalendarT
assertTrue(isCalendarInList(calendar), "Test calendar should be in the list");
CalendarListEntry calendarFromGet = requestBody("direct://GET", calendar.getId());
- assertTrue(calendar.getId().equals(calendarFromGet.getId()));
+ assertEquals(calendar.getId(), calendarFromGet.getId());
}
protected boolean isCalendarInList(Calendar calendar) {
diff --git a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarCalendarsIntegrationTest.java b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarCalendarsIntegrationTest.java
index e4a8431..1b87baa 100644
--- a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarCalendarsIntegrationTest.java
+++ b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarCalendarsIntegrationTest.java
@@ -27,7 +27,7 @@ import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
/**
@@ -43,7 +43,7 @@ public class CalendarCalendarsIntegrationTest extends AbstractGoogleCalendarTest
public void testCalendars() throws Exception {
Calendar calendar = getCalendar();
Calendar calendarFromGet = requestBody("direct://GET", calendar.getId());
- assertTrue(calendar.getId().equals(calendarFromGet.getId()));
+ assertEquals(calendar.getId(), calendarFromGet.getId());
final Map<String, Object> headers = new HashMap<>();
// parameter type is String
@@ -52,7 +52,7 @@ public class CalendarCalendarsIntegrationTest extends AbstractGoogleCalendarTest
headers.put("CamelGoogleCalendar.content", calendar.setDescription("foo"));
Calendar result = requestBodyAndHeaders("direct://UPDATE", null, headers);
- assertTrue("foo".equals(result.getDescription()));
+ assertEquals("foo", result.getDescription());
requestBody("direct://DELETE", calendar.getId());
try {
diff --git a/components/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/DriveFilesIntegrationTest.java b/components/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/DriveFilesIntegrationTest.java
index c766cc9..334a6e00 100644
--- a/components/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/DriveFilesIntegrationTest.java
+++ b/components/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/DriveFilesIntegrationTest.java
@@ -133,7 +133,7 @@ public class DriveFilesIntegrationTest extends AbstractGoogleDriveTestSupport {
result = requestBodyAndHeaders("direct://LIST", null, headers);
assertNotNull(result, "list result");
- assertTrue(result.getItems().size() == 1);
+ assertEquals(1, result.getItems().size());
// test paging the list
List<File> resultList = new ArrayList<>();
@@ -150,7 +150,7 @@ public class DriveFilesIntegrationTest extends AbstractGoogleDriveTestSupport {
} while (pageToken != null && pageToken.length() > 0 && i < 2);
// we should have 2 files in result (one file for each of the 2 pages)
- assertTrue(resultList.size() == 2);
+ assertEquals(2, resultList.size());
// they should be different files
assertFalse(resultList.get(0).getId().equals(resultList.get(1)));
}
diff --git a/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersLabelsIntegrationTest.java b/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersLabelsIntegrationTest.java
index ed40184..64358c0 100644
--- a/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersLabelsIntegrationTest.java
+++ b/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersLabelsIntegrationTest.java
@@ -28,7 +28,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Test class for {@link com.google.api.services.gmail.Gmail$Users$Labels} APIs.
@@ -65,7 +65,7 @@ public class GmailUsersLabelsIntegrationTest extends AbstractGoogleMailTestSuppo
// using String message body for single parameter "userId"
labels = requestBody("direct://LIST", CURRENT_USERID);
- assertTrue(getTestLabel(labels) != null);
+ assertNotNull(getTestLabel(labels));
Map<String, Object> headers = new HashMap<>();
// parameter type is String
@@ -77,7 +77,7 @@ public class GmailUsersLabelsIntegrationTest extends AbstractGoogleMailTestSuppo
// using String message body for single parameter "userId"
labels = requestBody("direct://LIST", CURRENT_USERID);
- assertTrue(getTestLabel(labels) == null);
+ assertNull(getTestLabel(labels));
}
private Label getTestLabel(com.google.api.services.gmail.model.ListLabelsResponse labels) {
diff --git a/components/camel-google-pubsub/src/test/java/org/apache/camel/component/google/pubsub/integration/BodyTypesTest.java b/components/camel-google-pubsub/src/test/java/org/apache/camel/component/google/pubsub/integration/BodyTypesTest.java
index e7dbf2b..a71a15f 100644
--- a/components/camel-google-pubsub/src/test/java/org/apache/camel/component/google/pubsub/integration/BodyTypesTest.java
+++ b/components/camel-google-pubsub/src/test/java/org/apache/camel/component/google/pubsub/integration/BodyTypesTest.java
@@ -37,6 +37,7 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class BodyTypesTest extends PubsubTestSupport {
@@ -100,7 +101,7 @@ public class BodyTypesTest extends PubsubTestSupport {
assertTrue(sentExchange.getIn().getBody() instanceof byte[], "Sent body type is byte[]");
- assertTrue(sentExchange.getIn().getBody() == body, "Sent body type is the one sent");
+ assertSame(body, sentExchange.getIn().getBody(), "Sent body type is the one sent");
receiveResult.assertIsSatisfied(5000);
@@ -149,7 +150,7 @@ public class BodyTypesTest extends PubsubTestSupport {
Object bodyReceived = deserialize((byte[]) receivedExchange.getIn().getBody());
- assertTrue(((Map) bodyReceived).get("KEY").equals("VALUE1212"), "Received body is a Map");
+ assertEquals("VALUE1212", ((Map) bodyReceived).get("KEY"), "Received body is a Map");
}