-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Wireless Transmitter and Range Upgrade
- Loading branch information
Showing
202 changed files
with
4,028 additions
and
92 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
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
210 changes: 210 additions & 0 deletions
210
...com/refinedmods/refinedstorage2/api/network/impl/component/GraphNetworkComponentTest.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,210 @@ | ||
package com.refinedmods.refinedstorage2.api.network.impl.component; | ||
|
||
import com.refinedmods.refinedstorage2.api.network.impl.NetworkImpl; | ||
import com.refinedmods.refinedstorage2.api.network.impl.node.SimpleNetworkNode; | ||
import com.refinedmods.refinedstorage2.api.network.node.NetworkNode; | ||
import com.refinedmods.refinedstorage2.api.network.node.container.NetworkNodeContainer; | ||
import com.refinedmods.refinedstorage2.network.test.NetworkTestFixtures; | ||
|
||
import java.util.Set; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class GraphNetworkComponentTest { | ||
GraphNetworkComponent sut; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
sut = new GraphNetworkComponent(new NetworkImpl(NetworkTestFixtures.NETWORK_COMPONENT_MAP_FACTORY)); | ||
} | ||
|
||
@Test | ||
void shouldAddContainer() { | ||
// Arrange | ||
final NetworkNodeContainer container1 = () -> new SimpleNetworkNode(0); | ||
final NetworkNodeContainer container2 = () -> new SimpleNetworkNode(0); | ||
|
||
// Act | ||
sut.onContainerAdded(container1); | ||
sut.onContainerAdded(container2); | ||
|
||
// Assert | ||
assertThat(sut.getContainers()).containsExactlyInAnyOrder(container1, container2); | ||
} | ||
|
||
@Test | ||
void shouldRemoveContainer() { | ||
// Arrange | ||
final NetworkNodeContainer container1 = () -> new SimpleNetworkNode(0); | ||
final NetworkNodeContainer container2 = () -> new SimpleNetworkNode(0); | ||
sut.onContainerAdded(container1); | ||
sut.onContainerAdded(container2); | ||
|
||
// Act | ||
sut.onContainerRemoved(container1); | ||
|
||
// Assert | ||
assertThat(sut.getContainers()).containsExactly(container2); | ||
} | ||
|
||
@Test | ||
void shouldNotRetrieveContainersByClassThatDontExist() { | ||
// Act | ||
final Set<NetworkNodeContainer1> containers = sut.getContainers(NetworkNodeContainer1.class); | ||
|
||
// Assert | ||
assertThat(containers).isEmpty(); | ||
} | ||
|
||
@Test | ||
void shouldAddAndRetrieveSingleContainerByClass() { | ||
// Arrange | ||
final NetworkNodeContainer1 container1 = new NetworkNodeContainer1(); | ||
final NetworkNodeContainer2 container2 = new NetworkNodeContainer2(); | ||
sut.onContainerAdded(container1); | ||
sut.onContainerAdded(container2); | ||
|
||
// Act | ||
final Set<NetworkNodeContainer1> containers = sut.getContainers(NetworkNodeContainer1.class); | ||
|
||
// Assert | ||
assertThat(containers).containsExactly(container1); | ||
} | ||
|
||
@Test | ||
void shouldAddAndRetrieveMultipleContainersByClass() { | ||
// Arrange | ||
final NetworkNodeContainer1 container11 = new NetworkNodeContainer1(); | ||
final NetworkNodeContainer1 container12 = new NetworkNodeContainer1(); | ||
final NetworkNodeContainer2 container2 = new NetworkNodeContainer2(); | ||
sut.onContainerAdded(container11); | ||
sut.onContainerAdded(container12); | ||
sut.onContainerAdded(container2); | ||
|
||
// Act | ||
final Set<NetworkNodeContainer1> containers = sut.getContainers(NetworkNodeContainer1.class); | ||
|
||
// Assert | ||
assertThat(containers).containsExactlyInAnyOrder(container11, container12); | ||
} | ||
|
||
@Test | ||
void shouldAddAndRetrieveMultipleContainersByInterface() { | ||
// Arrange | ||
final NetworkNodeContainer1 container11 = new NetworkNodeContainer1(); | ||
final NetworkNodeContainer1 container12 = new NetworkNodeContainer1(); | ||
final NetworkNodeContainer2 container2 = new NetworkNodeContainer2(); | ||
sut.onContainerAdded(container11); | ||
sut.onContainerAdded(container12); | ||
sut.onContainerAdded(container2); | ||
|
||
// Act | ||
final Set<BothImplements> containers = sut.getContainers(BothImplements.class); | ||
|
||
// Assert | ||
assertThat(containers).containsExactlyInAnyOrder(container11, container12, container2); | ||
} | ||
|
||
@Test | ||
void shouldRemoveSingleContainerAndRetrieveByClass() { | ||
// Arrange | ||
final NetworkNodeContainer1 container11 = new NetworkNodeContainer1(); | ||
final NetworkNodeContainer1 container12 = new NetworkNodeContainer1(); | ||
final NetworkNodeContainer2 container2 = new NetworkNodeContainer2(); | ||
sut.onContainerAdded(container11); | ||
sut.onContainerAdded(container12); | ||
sut.onContainerAdded(container2); | ||
|
||
// Act | ||
sut.onContainerRemoved(container12); | ||
|
||
final Set<NetworkNodeContainer1> containers = sut.getContainers(NetworkNodeContainer1.class); | ||
|
||
// Assert | ||
assertThat(containers).containsExactly(container11); | ||
} | ||
|
||
@Test | ||
void shouldRemoveSingleContainerAndRetrieveByInterface() { | ||
// Arrange | ||
final NetworkNodeContainer1 container11 = new NetworkNodeContainer1(); | ||
final NetworkNodeContainer1 container12 = new NetworkNodeContainer1(); | ||
final NetworkNodeContainer2 container2 = new NetworkNodeContainer2(); | ||
sut.onContainerAdded(container11); | ||
sut.onContainerAdded(container12); | ||
sut.onContainerAdded(container2); | ||
|
||
// Act | ||
sut.onContainerRemoved(container12); | ||
|
||
final Set<BothImplements> containers = sut.getContainers(BothImplements.class); | ||
|
||
// Assert | ||
assertThat(containers).containsExactlyInAnyOrder(container11, container2); | ||
} | ||
|
||
@Test | ||
void shouldRemoveMultipleContainersAndRetrieveByClass() { | ||
// Arrange | ||
final NetworkNodeContainer1 container11 = new NetworkNodeContainer1(); | ||
final NetworkNodeContainer1 container12 = new NetworkNodeContainer1(); | ||
final NetworkNodeContainer2 container2 = new NetworkNodeContainer2(); | ||
sut.onContainerAdded(container11); | ||
sut.onContainerAdded(container12); | ||
sut.onContainerAdded(container2); | ||
|
||
// Act | ||
sut.onContainerRemoved(container11); | ||
sut.onContainerRemoved(container12); | ||
|
||
final Set<NetworkNodeContainer1> containers1 = sut.getContainers(NetworkNodeContainer1.class); | ||
final Set<NetworkNodeContainer2> containers2 = sut.getContainers(NetworkNodeContainer2.class); | ||
final Set<BothImplements> containersByIface = sut.getContainers(BothImplements.class); | ||
|
||
// Assert | ||
assertThat(containers1).isEmpty(); | ||
assertThat(containers2).containsExactly(container2); | ||
assertThat(containersByIface).containsExactly(container2); | ||
} | ||
|
||
@Test | ||
void shouldRemoveMultipleContainersAndRetrieveByInterface() { | ||
// Arrange | ||
final NetworkNodeContainer1 container11 = new NetworkNodeContainer1(); | ||
final NetworkNodeContainer1 container12 = new NetworkNodeContainer1(); | ||
final NetworkNodeContainer2 container2 = new NetworkNodeContainer2(); | ||
sut.onContainerAdded(container11); | ||
sut.onContainerAdded(container12); | ||
sut.onContainerAdded(container2); | ||
|
||
// Act | ||
sut.onContainerRemoved(container11); | ||
sut.onContainerRemoved(container12); | ||
sut.onContainerRemoved(container2); | ||
|
||
final Set<BothImplements> containers = sut.getContainers(BothImplements.class); | ||
|
||
// Assert | ||
assertThat(containers).isEmpty(); | ||
} | ||
|
||
private static class NetworkNodeContainer1 implements NetworkNodeContainer, BothImplements { | ||
@Override | ||
public NetworkNode getNode() { | ||
return new SimpleNetworkNode(0); | ||
} | ||
} | ||
|
||
private static class NetworkNodeContainer2 implements NetworkNodeContainer, BothImplements { | ||
@Override | ||
public NetworkNode getNode() { | ||
return new SimpleNetworkNode(0); | ||
} | ||
} | ||
|
||
private interface BothImplements { | ||
} | ||
} |
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
Oops, something went wrong.