-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjusted code formatting of
StopStreaming
and added null checks for…
… constructor arguments. Added unit tests for `StopStreaming`. Signed-off-by: Juergen Fickel <juergen.fickel@bosch-si.com>
- Loading branch information
Juergen Fickel
committed
Oct 16, 2019
1 parent
e9783ba
commit 1ea3991
Showing
2 changed files
with
90 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...reaming/src/test/java/org/eclipse/ditto/services/gateway/streaming/StopStreamingTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (c) 2019 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.eclipse.ditto.services.gateway.streaming; | ||
|
||
import static org.assertj.core.api.Assertions.assertThatNullPointerException; | ||
import static org.mutabilitydetector.unittesting.MutabilityAssert.assertInstancesOf; | ||
import static org.mutabilitydetector.unittesting.MutabilityMatchers.areImmutable; | ||
|
||
import org.assertj.core.api.SoftAssertions; | ||
import org.eclipse.ditto.services.models.concierge.streaming.StreamingType; | ||
import org.junit.Test; | ||
|
||
import nl.jqno.equalsverifier.EqualsVerifier; | ||
|
||
/** | ||
* Unit test for {@link StopStreaming}. | ||
*/ | ||
public final class StopStreamingTest { | ||
|
||
@Test | ||
public void assertImmutability() { | ||
assertInstancesOf(StopStreaming.class, areImmutable()); | ||
} | ||
|
||
@Test | ||
public void testHashCodeAndEquals() { | ||
EqualsVerifier.forClass(StopStreaming.class) | ||
.usingGetClass() | ||
.verify(); | ||
} | ||
|
||
@Test | ||
public void tryToCreateInstanceWithNullStreamingType() { | ||
assertThatNullPointerException() | ||
.isThrownBy(() -> new StopStreaming(null, "my-correlation-id")) | ||
.withMessage("The streamingType must not be null!") | ||
.withNoCause(); | ||
} | ||
|
||
@Test | ||
public void tryToCreateInstanceWithNullCorrelationId() { | ||
assertThatNullPointerException() | ||
.isThrownBy(() -> new StopStreaming(StreamingType.LIVE_COMMANDS, null)) | ||
.withMessage("The connectionCorrelationId must not be null!") | ||
.withNoCause(); | ||
} | ||
|
||
@Test | ||
public void gettersReturnExpected() { | ||
final StreamingType streamingType = StreamingType.EVENTS; | ||
final String connectionCorrelationId = "my-correlation-id"; | ||
|
||
final StopStreaming underTest = new StopStreaming(streamingType, connectionCorrelationId); | ||
|
||
final SoftAssertions softly = new SoftAssertions(); | ||
softly.assertThat(underTest.getStreamingType()).isEqualTo(streamingType); | ||
softly.assertThat(underTest.getConnectionCorrelationId()).isEqualTo(connectionCorrelationId); | ||
softly.assertAll(); | ||
} | ||
|
||
} |