MAILBOX-359 Re-arrange QuotaUsageUpdatedEventSerializationTest WithTime success case is strictly equivalent to the success case
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/5383b12e Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/5383b12e Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/5383b12e Branch: refs/heads/master Commit: 5383b12ebd3a1f020f67782f239a5ebc04bcee92 Parents: c6aebcc Author: Benoit Tellier <btell...@linagora.com> Authored: Mon Dec 24 15:25:59 2018 +0700 Committer: Benoit Tellier <btell...@linagora.com> Committed: Tue Jan 8 14:37:57 2019 +0700 ---------------------------------------------------------------------- ...QuotaUsageUpdatedEventSerializationTest.java | 81 +++++++------------- 1 file changed, 26 insertions(+), 55 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/5383b12e/mailbox/event/json/src/test/java/org/apache/james/event/json/QuotaUsageUpdatedEventSerializationTest.java ---------------------------------------------------------------------- diff --git a/mailbox/event/json/src/test/java/org/apache/james/event/json/QuotaUsageUpdatedEventSerializationTest.java b/mailbox/event/json/src/test/java/org/apache/james/event/json/QuotaUsageUpdatedEventSerializationTest.java index af95172..f0cbe7f 100644 --- a/mailbox/event/json/src/test/java/org/apache/james/event/json/QuotaUsageUpdatedEventSerializationTest.java +++ b/mailbox/event/json/src/test/java/org/apache/james/event/json/QuotaUsageUpdatedEventSerializationTest.java @@ -51,19 +51,6 @@ class QuotaUsageUpdatedEventSerializationTest { .computedLimit(QuotaSize.size(10000)) .build(); private static final Instant INSTANT = Instant.parse("2018-11-13T12:00:55Z"); - private static final MailboxListener.QuotaUsageUpdatedEvent DEFAULT_QUOTA_EVENT = - new MailboxListener.QuotaUsageUpdatedEvent(USER, QUOTA_ROOT, QUOTA_COUNT, QUOTA_SIZE, INSTANT); - - private static final String DEFAULT_QUOTA_EVENT_JSON = - "{" + - "\"QuotaUsageUpdatedEvent\":{" + - "\"quotaRoot\":\"foo\"," + - "\"countQuota\":{\"used\":12,\"limit\":100,\"limits\":{}}," + - "\"time\":\"2018-11-13T12:00:55Z\"," + - "\"sizeQuota\":{\"used\":1234,\"limit\":10000,\"limits\":{}}," + - "\"user\":\"user\"" + - "}" + - "}"; private static final EventSerializer EVENT_SERIALIZER = new EventSerializer(new TestId.Factory(), new TestMessageId.Factory()); @@ -540,52 +527,36 @@ class QuotaUsageUpdatedEventSerializationTest { } } - @Nested - class WithTime { - - @Test - void toJsonShouldReturnSerializedJsonEventWhenTimeIsValid() { - assertThatJson(EVENT_SERIALIZER.toJson(DEFAULT_QUOTA_EVENT)) - .isEqualTo(DEFAULT_QUOTA_EVENT_JSON); - } - - @Test - void fromJsonShouldReturnDeSerializedEventWhenTimeIsValid() { - assertThat(EVENT_SERIALIZER.fromJson(DEFAULT_QUOTA_EVENT_JSON).get()) - .isEqualTo(DEFAULT_QUOTA_EVENT); - } - - @Test - void fromJsonShouldThrowResultWhenTimeIsNull() { - String quotaUsageUpdatedEvent = - "{" + - "\"QuotaUsageUpdatedEvent\":{" + - "\"quotaRoot\":\"foo\"," + - "\"countQuota\":{\"used\":12,\"limit\":100,\"limits\":{\"Domain\":100}}," + - "\"sizeQuota\":{\"used\":1234,\"limit\":10000,\"limits\":{}}," + - "\"user\":\"user\"" + - "}" + + @Test + void fromJsonShouldThrowResultWhenTimeIsNull() { + String quotaUsageUpdatedEvent = + "{" + + "\"QuotaUsageUpdatedEvent\":{" + + "\"quotaRoot\":\"foo\"," + + "\"countQuota\":{\"used\":12,\"limit\":100,\"limits\":{\"Domain\":100}}," + + "\"sizeQuota\":{\"used\":1234,\"limit\":10000,\"limits\":{}}," + + "\"user\":\"user\"" + + "}" + "}"; - assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(quotaUsageUpdatedEvent).get()) - .isInstanceOf(NoSuchElementException.class); - } + assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(quotaUsageUpdatedEvent).get()) + .isInstanceOf(NoSuchElementException.class); + } - @Test - void fromJsonShouldThrowResultWhenTimeIsEmpty() { - String quotaUsageUpdatedEvent = - "{" + - "\"QuotaUsageUpdatedEvent\":{" + - "\"quotaRoot\":\"foo\"," + - "\"countQuota\":{\"used\":12,\"limit\":100,\"limits\":{\"Domain\":100}}," + - "\"time\":\"\"," + - "\"sizeQuota\":{\"used\":1234,\"limit\":10000,\"limits\":{}}," + - "\"user\":\"user\"" + - "}" + + @Test + void fromJsonShouldThrowResultWhenTimeIsEmpty() { + String quotaUsageUpdatedEvent = + "{" + + "\"QuotaUsageUpdatedEvent\":{" + + "\"quotaRoot\":\"foo\"," + + "\"countQuota\":{\"used\":12,\"limit\":100,\"limits\":{\"Domain\":100}}," + + "\"time\":\"\"," + + "\"sizeQuota\":{\"used\":1234,\"limit\":10000,\"limits\":{}}," + + "\"user\":\"user\"" + + "}" + "}"; - assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(quotaUsageUpdatedEvent).get()) - .isInstanceOf(NoSuchElementException.class); - } + assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(quotaUsageUpdatedEvent).get()) + .isInstanceOf(NoSuchElementException.class); } } --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org