Skip to content

Commit

Permalink
refactor: unify storage block and disk drive network nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
raoulvdberge committed Jun 22, 2024
1 parent 545021a commit ac9755c
Show file tree
Hide file tree
Showing 30 changed files with 700 additions and 1,300 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.refinedmods.refinedstorage2.api.network.impl.node.grid.GridNetworkNode;
import com.refinedmods.refinedstorage2.api.network.impl.node.iface.InterfaceNetworkNode;
import com.refinedmods.refinedstorage2.api.network.impl.node.importer.ImporterNetworkNode;
import com.refinedmods.refinedstorage2.api.network.impl.node.multistorage.MultiStorageNetworkNode;
import com.refinedmods.refinedstorage2.api.network.impl.node.relay.RelayInputNetworkNode;
import com.refinedmods.refinedstorage2.api.network.impl.node.relay.RelayOutputNetworkNode;
import com.refinedmods.refinedstorage2.api.network.impl.node.storage.StorageNetworkNode;
Expand All @@ -19,7 +18,6 @@
import com.refinedmods.refinedstorage2.network.test.nodefactory.GridNetworkNodeFactory;
import com.refinedmods.refinedstorage2.network.test.nodefactory.ImporterNetworkNodeFactory;
import com.refinedmods.refinedstorage2.network.test.nodefactory.InterfaceNetworkNodeFactory;
import com.refinedmods.refinedstorage2.network.test.nodefactory.MultiStorageNetworkNodeFactory;
import com.refinedmods.refinedstorage2.network.test.nodefactory.RelayInputNetworkNodeFactory;
import com.refinedmods.refinedstorage2.network.test.nodefactory.RelayOutputNetworkNodeFactory;
import com.refinedmods.refinedstorage2.network.test.nodefactory.SimpleNetworkNodeFactory;
Expand All @@ -36,12 +34,11 @@
@Target(ElementType.TYPE)
@ExtendWith(NetworkTestExtension.class)
@RegisterNetworkNode(value = ControllerNetworkNodeFactory.class, clazz = ControllerNetworkNode.class)
@RegisterNetworkNode(value = MultiStorageNetworkNodeFactory.class, clazz = MultiStorageNetworkNode.class)
@RegisterNetworkNode(value = StorageNetworkNodeFactory.class, clazz = StorageNetworkNode.class)
@RegisterNetworkNode(value = ExporterNetworkNodeFactory.class, clazz = ExporterNetworkNode.class)
@RegisterNetworkNode(value = GridNetworkNodeFactory.class, clazz = GridNetworkNode.class)
@RegisterNetworkNode(value = ImporterNetworkNodeFactory.class, clazz = ImporterNetworkNode.class)
@RegisterNetworkNode(value = SimpleNetworkNodeFactory.class, clazz = SimpleNetworkNode.class)
@RegisterNetworkNode(value = StorageNetworkNodeFactory.class, clazz = StorageNetworkNode.class)
@RegisterNetworkNode(value = InterfaceNetworkNodeFactory.class, clazz = InterfaceNetworkNode.class)
@RegisterNetworkNode(value = ExternalStorageNetworkNodeFactory.class, clazz = ExternalStorageNetworkNode.class)
@RegisterNetworkNode(value = DetectorNetworkNodeFactory.class, clazz = DetectorNetworkNode.class)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,17 @@
import java.util.Map;

public class StorageNetworkNodeFactory extends AbstractNetworkNodeFactory {
public static final String PROPERTY_ENERGY_USAGE_PER_STORAGE = "energy_usage_per_storage";
public static final String PROPERTY_SIZE = "size";

@Override
protected AbstractNetworkNode innerCreate(final AddNetworkNode ctx, final Map<String, Object> properties) {
return new StorageNetworkNode(getEnergyUsage(properties));
final long energyUsagePerStorage = (long) properties.getOrDefault(PROPERTY_ENERGY_USAGE_PER_STORAGE, 0L);
final int size = (int) properties.getOrDefault(PROPERTY_SIZE, 9);
return new StorageNetworkNode(
getEnergyUsage(properties),
energyUsagePerStorage,
size
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import com.refinedmods.refinedstorage2.api.network.impl.node.grid.GridNetworkNode;
import com.refinedmods.refinedstorage2.api.network.impl.node.iface.InterfaceNetworkNode;
import com.refinedmods.refinedstorage2.api.network.impl.node.importer.ImporterNetworkNode;
import com.refinedmods.refinedstorage2.api.network.impl.node.multistorage.MultiStorageNetworkNode;
import com.refinedmods.refinedstorage2.api.network.impl.node.relay.RelayInputNetworkNode;
import com.refinedmods.refinedstorage2.api.network.impl.node.relay.RelayOutputNetworkNode;
import com.refinedmods.refinedstorage2.api.network.impl.node.storage.StorageNetworkNode;

import org.junit.jupiter.api.Test;
Expand All @@ -21,8 +22,6 @@ class NetworkNodeFactoryTest {
@AddNetworkNode
ControllerNetworkNode controller;
@AddNetworkNode
MultiStorageNetworkNode multiStorage;
@AddNetworkNode
ExporterNetworkNode exporter;
@AddNetworkNode
GridNetworkNode grid;
Expand All @@ -38,6 +37,10 @@ class NetworkNodeFactoryTest {
ExternalStorageNetworkNode externalStorage;
@AddNetworkNode
DetectorNetworkNode detector;
@AddNetworkNode
RelayInputNetworkNode relayInput;
@AddNetworkNode
RelayOutputNetworkNode relayOutput;

@Test
void testInitialization() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
import com.refinedmods.refinedstorage2.api.network.Network;
import com.refinedmods.refinedstorage2.api.network.energy.EnergyNetworkComponent;
import com.refinedmods.refinedstorage2.api.network.impl.node.SimpleNetworkNode;
import com.refinedmods.refinedstorage2.api.network.impl.node.multistorage.MultiStorageNetworkNode;
import com.refinedmods.refinedstorage2.api.network.impl.node.storage.StorageNetworkNode;
import com.refinedmods.refinedstorage2.api.network.node.GraphNetworkComponent;
import com.refinedmods.refinedstorage2.api.network.node.container.NetworkNodeContainer;
import com.refinedmods.refinedstorage2.api.network.security.SecurityNetworkComponent;
import com.refinedmods.refinedstorage2.api.network.storage.StorageNetworkComponent;
import com.refinedmods.refinedstorage2.network.test.nodefactory.AbstractNetworkNodeFactory;
import com.refinedmods.refinedstorage2.network.test.nodefactory.MultiStorageNetworkNodeFactory;
import com.refinedmods.refinedstorage2.network.test.nodefactory.SimpleNetworkNodeFactory;
import com.refinedmods.refinedstorage2.network.test.nodefactory.StorageNetworkNodeFactory;

Expand All @@ -23,7 +21,7 @@
@ExtendWith({NetworkTestExtension.class})
@SetupNetwork(id = "a", energyCapacity = 100, energyStored = 50)
@SetupNetwork(id = "b")
@RegisterNetworkNode(value = MultiStorageNetworkNodeFactory.class, clazz = MultiStorageNetworkNode.class)
@RegisterNetworkNode(value = StorageNetworkNodeFactory.class, clazz = StorageNetworkNode.class)
@RegisterNetworkNode(value = StorageNetworkNodeFactory.class, clazz = StorageNetworkNode.class)
@RegisterNetworkNode(value = SimpleNetworkNodeFactory.class, clazz = SimpleNetworkNode.class)
class NetworkTestExtensionTest {
Expand All @@ -41,7 +39,7 @@ class NetworkTestExtensionTest {
@AddNetworkNode(networkId = "b", properties = {
@AddNetworkNode.Property(key = AbstractNetworkNodeFactory.PROPERTY_ACTIVE, boolValue = false)
})
MultiStorageNetworkNode storageInB;
StorageNetworkNode storageInB;

@AddNetworkNode(networkId = "nonexistent")
SimpleNetworkNode nonexistentNetworkNode;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit ac9755c

Please sign in to comment.