This is an automated email from the ASF dual-hosted git repository. matthieu pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 2a8c675df8aea0a99eb2bead29e5bed2b0de256f Author: Rémi KOWALSKI <rkowal...@linagora.com> AuthorDate: Thu Dec 12 16:49:53 2019 +0100 JAMES-3009 convert event sourcing pojo tests to scala --- .../apache/james/eventsourcing/EventIdTest.java | 85 ---------------------- .../apache/james/eventsourcing/EventIdTest.scala | 68 +++++++++++++++++ 2 files changed, 68 insertions(+), 85 deletions(-) diff --git a/event-sourcing/event-sourcing-pojo/src/test/java/org/apache/james/eventsourcing/EventIdTest.java b/event-sourcing/event-sourcing-pojo/src/test/java/org/apache/james/eventsourcing/EventIdTest.java deleted file mode 100644 index e411e39..0000000 --- a/event-sourcing/event-sourcing-pojo/src/test/java/org/apache/james/eventsourcing/EventIdTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one * - * or more contributor license agreements. See the NOTICE file * - * distributed with this work for additional information * - * regarding copyright ownership. The ASF licenses this file * - * to you under the Apache License, Version 2.0 (the * - * "License"); you may not use this file except in compliance * - * with the License. You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, * - * software distributed under the License is distributed on an * - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * - * KIND, either express or implied. See the License for the * - * specific language governing permissions and limitations * - * under the License. * - ****************************************************************/ - -package org.apache.james.eventsourcing; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.jupiter.api.Test; - -import nl.jqno.equalsverifier.EqualsVerifier; -import scala.jdk.javaapi.OptionConverters; - -class EventIdTest { - - @Test - void shouldMatchBeanContract() { - EqualsVerifier.forClass(EventId.class) - .verify(); - } - - @Test - void firstShouldReturnAConstant() { - assertThat(EventId.first()) - .isEqualTo(EventId.first()); - } - - @Test - void previousShouldReturnEmptyWhenBeforeFirst() { - assertThat(OptionConverters.toJava(EventId.first().previous())) - .isEmpty(); - } - - @Test - void compareToShouldReturnNegativeWhenComparedToNext() { - assertThat(EventId.first()) - .isLessThan(EventId.first().next()); - } - - @Test - void compareToShouldReturnNegativeWhenComparedToPrevious() { - assertThat(EventId.first().next()) - .isGreaterThan(EventId.first()); - } - - @Test - void nextShouldAlwaysHaveTheSameIncrement() { - assertThat(EventId.first().next()) - .isEqualTo(EventId.first().next()); - } - - @Test - void previousShouldRevertNext() { - assertThat(OptionConverters.toJava(EventId.first().next().previous())) - .contains(EventId.first()); - } - - @Test - void compareToShouldReturnNegativeWhenComparedToNextWithPreviousCall() { - assertThat(EventId.first().next().previous().get()) - .isLessThan(EventId.first().next()); - } - - @Test - void compareToShouldReturnNegativeWhenComparedToPreviousWithPreviousCall() { - assertThat(EventId.first().next()) - .isGreaterThan(EventId.first().next().previous().get()); - } - -} \ No newline at end of file diff --git a/event-sourcing/event-sourcing-pojo/src/test/scala/org/apache/james/eventsourcing/EventIdTest.scala b/event-sourcing/event-sourcing-pojo/src/test/scala/org/apache/james/eventsourcing/EventIdTest.scala new file mode 100644 index 0000000..d015368 --- /dev/null +++ b/event-sourcing/event-sourcing-pojo/src/test/scala/org/apache/james/eventsourcing/EventIdTest.scala @@ -0,0 +1,68 @@ + /*************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ +package org.apache.james.eventsourcing + +import nl.jqno.equalsverifier.EqualsVerifier +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class EventIdTest { + @Test + def shouldMatchBeanContract(): Unit = EqualsVerifier.forClass(classOf[EventId]).verify() + + @Test + def firstShouldReturnAConstant(): Unit = + assertThat(EventId.first) + .isEqualTo(EventId.first) + + @Test + def previousShouldReturnEmptyWhenBeforeFirst(): Unit = + assertThat(EventId.first.previous) + .isEqualTo(None) + + @Test + def compareToShouldReturnNegativeWhenComparedToNext(): Unit = + assertThat(EventId.first) + .isLessThan(EventId.first.next) + + @Test + def compareToShouldReturnNegativeWhenComparedToPrevious(): Unit = + assertThat(EventId.first.next) + .isGreaterThan(EventId.first) + + @Test + def nextShouldAlwaysHaveTheSameIncrement(): Unit = + assertThat(EventId.first.next) + .isEqualTo(EventId.first.next) + + @Test + def previousShouldRevertNext(): Unit = + assertThat(EventId.first.next.previous) + .isEqualTo(Some(EventId.first)) + + @Test + def compareToShouldReturnNegativeWhenComparedToNextWithPreviousCall(): Unit = + assertThat(EventId.first.next.previous.get) + .isLessThan(EventId.first.next) + + @Test + def compareToShouldReturnNegativeWhenComparedToPreviousWithPreviousCall(): Unit = + assertThat(EventId.first.next) + .isGreaterThan(EventId.first.next.previous.get) +} \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org