-
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.
…to package level. Added a unit test. Signed-off-by: Juergen Fickel <juergen.fickel@bosch.io>
- Loading branch information
Juergen Fickel
committed
Apr 29, 2021
1 parent
bb47f2d
commit a5ef80e
Showing
4 changed files
with
230 additions
and
81 deletions.
There are no files selected for viewing
131 changes: 131 additions & 0 deletions
131
protocol-adapter/src/main/java/org/eclipse/ditto/protocoladapter/EmptyTopicPath.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,131 @@ | ||
/* | ||
* Copyright (c) 2021 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.protocoladapter; | ||
|
||
import java.util.Optional; | ||
|
||
import javax.annotation.Nullable; | ||
import javax.annotation.concurrent.Immutable; | ||
|
||
/** | ||
* Implementation of an empty {@link TopicPath}. | ||
*/ | ||
@Immutable | ||
final class EmptyTopicPath implements TopicPath { | ||
|
||
private EmptyTopicPath() { | ||
super(); | ||
} | ||
|
||
/** | ||
* Returns an instance of {@code EmptyTopicPath}. | ||
* | ||
* @return the instance. | ||
*/ | ||
static EmptyTopicPath getInstance() { | ||
return new EmptyTopicPath(); | ||
} | ||
|
||
/** | ||
* @return always {@code null}. | ||
*/ | ||
@Override | ||
@Nullable | ||
public String getNamespace() { | ||
return null; | ||
} | ||
|
||
/** | ||
* @return always {@code null}. | ||
*/ | ||
@Override | ||
@Nullable | ||
public String getEntityName() { | ||
return null; | ||
} | ||
|
||
/** | ||
* @return always {@code null}. | ||
*/ | ||
@Override | ||
@Nullable | ||
public Group getGroup() { | ||
return null; | ||
} | ||
|
||
/** | ||
* @return always {@code null}. | ||
*/ | ||
@Override | ||
@Nullable | ||
public Criterion getCriterion() { | ||
return null; | ||
} | ||
|
||
/** | ||
* @return always {@code null}. | ||
*/ | ||
@Override | ||
@Nullable | ||
public Channel getChannel() { | ||
return null; | ||
} | ||
|
||
/** | ||
* @return always an empty Optional. | ||
*/ | ||
@Override | ||
public Optional<Action> getAction() { | ||
return Optional.empty(); | ||
} | ||
|
||
/** | ||
* @return always an empty Optional. | ||
*/ | ||
@Override | ||
public Optional<SearchAction> getSearchAction() { | ||
return Optional.empty(); | ||
} | ||
|
||
/** | ||
* @return always an empty Optional. | ||
*/ | ||
@Override | ||
public Optional<String> getSubject() { | ||
return Optional.empty(); | ||
} | ||
|
||
/** | ||
* @return always an empty String. | ||
*/ | ||
@Override | ||
public String getPath() { | ||
return ""; | ||
} | ||
|
||
@Override | ||
public boolean equals(@Nullable final Object o) { | ||
return this == o || !(o == null || getClass() != o.getClass()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return EmptyTopicPath.class.hashCode(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return getClass().getSimpleName() + "[]"; | ||
} | ||
|
||
} |
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
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
98 changes: 98 additions & 0 deletions
98
protocol-adapter/src/test/java/org/eclipse/ditto/protocoladapter/EmptyTopicPathTest.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,98 @@ | ||
/* | ||
* Copyright (c) 2021 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.protocoladapter; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mutabilitydetector.unittesting.MutabilityAssert.assertInstancesOf; | ||
import static org.mutabilitydetector.unittesting.MutabilityMatchers.areImmutable; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import nl.jqno.equalsverifier.EqualsVerifier; | ||
|
||
/** | ||
* Unit test for {@link EmptyTopicPathTest}. | ||
*/ | ||
public final class EmptyTopicPathTest { | ||
|
||
private EmptyTopicPath underTest; | ||
|
||
@Before | ||
public void setUp() { | ||
underTest = EmptyTopicPath.getInstance(); | ||
} | ||
|
||
@Test | ||
public void assertImmutability() { | ||
assertInstancesOf(EmptyTopicPath.class, areImmutable()); | ||
} | ||
|
||
@Test | ||
public void testHashCodeAndEquals() { | ||
EqualsVerifier.forClass(EmptyTopicPath.class) | ||
.usingGetClass() | ||
.verify(); | ||
} | ||
|
||
@Test | ||
public void getInstanceReturnsNotNull() { | ||
assertThat(EmptyTopicPath.getInstance()).isNotNull(); | ||
} | ||
|
||
@Test | ||
public void getNamespaceReturnsNull() { | ||
assertThat(underTest.getNamespace()).isNull(); | ||
} | ||
|
||
@Test | ||
public void getEntityNameReturnsNull() { | ||
assertThat(underTest.getEntityName()).isNull(); | ||
} | ||
|
||
@Test | ||
public void getGroupReturnsNull() { | ||
assertThat(underTest.getGroup()).isNull(); | ||
} | ||
|
||
@Test | ||
public void getCriterionReturnsNull() { | ||
assertThat(underTest.getCriterion()).isNull(); | ||
} | ||
|
||
@Test | ||
public void getChannelReturnsNull() { | ||
assertThat(underTest.getChannel()).isNull(); | ||
} | ||
|
||
@Test | ||
public void getActionReturnsEmptyOptional() { | ||
assertThat(underTest.getAction()).isEmpty(); | ||
} | ||
|
||
@Test | ||
public void getSearchActionReturnsEmptyOptional() { | ||
assertThat(underTest.getSearchAction()).isEmpty(); | ||
} | ||
|
||
@Test | ||
public void getSubjectReturnsEmptyOptional() { | ||
assertThat(underTest.getSubject()).isEmpty(); | ||
} | ||
|
||
@Test | ||
public void getPathReturnsEmptyString() { | ||
assertThat(underTest.getPath()).isEmpty(); | ||
} | ||
|
||
} |