diff --git a/gcm4/src/main/java/plugins/materials/actors/MaterialsProducerResourceReport.java b/gcm4/src/main/java/plugins/materials/actors/MaterialsProducerResourceReport.java index eddb3526d..268f28f07 100644 --- a/gcm4/src/main/java/plugins/materials/actors/MaterialsProducerResourceReport.java +++ b/gcm4/src/main/java/plugins/materials/actors/MaterialsProducerResourceReport.java @@ -126,7 +126,7 @@ public void init(final ActorContext actorContext) { } } - public void handleMaterialsProducerAdditionEvent(ActorContext actorContext, MaterialsProducerAdditionEvent materialsProducerAdditionEvent) { + private void handleMaterialsProducerAdditionEvent(ActorContext actorContext, MaterialsProducerAdditionEvent materialsProducerAdditionEvent) { MaterialsProducerId materialsProducerId = materialsProducerAdditionEvent.getMaterialsProducerId(); ResourcesDataManager resourcesDataManager = actorContext.getDataManager(ResourcesDataManager.class); MaterialsDataManager materialsDataManager = actorContext.getDataManager(MaterialsDataManager.class); diff --git a/gcm4/src/main/java/plugins/materials/datamangers/MaterialsDataManager.java b/gcm4/src/main/java/plugins/materials/datamangers/MaterialsDataManager.java index fee5317d5..50b6453cd 100644 --- a/gcm4/src/main/java/plugins/materials/datamangers/MaterialsDataManager.java +++ b/gcm4/src/main/java/plugins/materials/datamangers/MaterialsDataManager.java @@ -1697,8 +1697,6 @@ private void destroyBatch(final BatchId batchId) { * property definition *
  • {@linkplain MaterialsError#OFFERED_STAGE_UNALTERABLE} if * the batch in on an offered stage
  • - *
  • {@linkplain MaterialsError#MATERIALS_OWNERSHIP} if the - * requesting agent is not the owning materials producer
  • * * * @@ -1797,8 +1795,6 @@ private void validateMaterialProducerPropertyValueNotNull(final Object propertyV * is null *
  • {@linkplain MaterialsError#UNKNOWN_BATCH_ID} if the batch * id is unknown
  • - *
  • {@linkplain MaterialsError#MATERIALS_OWNERSHIP} if the - * requesting agent is not the owning materials producer
  • *
  • {@linkplain MaterialsError#BATCH_NOT_STAGED} if the batch * is not staged
  • *
  • {@linkplain MaterialsError#OFFERED_STAGE_UNALTERABLE } if @@ -1855,8 +1851,6 @@ private void validateBatchIsStaged(final BatchId batchId) { *
  • {@linkplain MaterialsError#BATCH_STAGED_TO_DIFFERENT_OWNER} * if batch and stage do not have the same owning materials * producer
  • - *
  • {@linkplain MaterialsError#MATERIALS_OWNERSHIP} if the - * requesting agent is not the owning material producer
  • * * */ @@ -2153,8 +2147,6 @@ public void setStageOfferState(StageId stageId, boolean offer) { * is null *
  • {@linkplain MaterialsError#UNKNOWN_STAGE_ID} if stage id * is unknown
  • - *
  • {@linkplain MaterialsError#MATERIALS_OWNERSHIP} if the - * requesting agent is not the owning materials producer
  • *
  • {@linkplain MaterialsError#OFFERED_STAGE_UNALTERABLE} if * the stage is offered
  • *
  • {@linkplain MaterialsError#NON_FINITE_MATERIAL_AMOUNT} if @@ -2236,8 +2228,6 @@ public BatchId convertStageToBatch(StageId stageId, MaterialId materialId, doubl * id is unknown
  • *
  • {@linkplain MaterialsError#OFFERED_STAGE_UNALTERABLE} if * the stage is offered
  • - *
  • {@linkplain MaterialsError#MATERIALS_OWNERSHIP} if the - * requesting agent is not the owning materials producer
  • *
  • {@linkplain ResourceError#NEGATIVE_RESOURCE_AMOUNT} if * the the resource amount is negative
  • *
  • {@linkplain ResourceError#RESOURCE_ARITHMETIC_EXCEPTION} diff --git a/gcm4/src/main/java/plugins/materials/events/MaterialsProducerAdditionEvent.java b/gcm4/src/main/java/plugins/materials/events/MaterialsProducerAdditionEvent.java index 08b924490..77bd4434c 100644 --- a/gcm4/src/main/java/plugins/materials/events/MaterialsProducerAdditionEvent.java +++ b/gcm4/src/main/java/plugins/materials/events/MaterialsProducerAdditionEvent.java @@ -43,6 +43,8 @@ public static class Builder { private Data data = new Data(); + private Builder(){} + private void validate() { if (data.materialsProducerId == null) { throw new ContractException(MaterialsError.NULL_MATERIALS_PRODUCER_ID); diff --git a/gcm4/src/main/java/plugins/materials/events/MaterialsProducerPropertyDefinitionEvent.java b/gcm4/src/main/java/plugins/materials/events/MaterialsProducerPropertyDefinitionEvent.java index ac189679f..5f5f44805 100644 --- a/gcm4/src/main/java/plugins/materials/events/MaterialsProducerPropertyDefinitionEvent.java +++ b/gcm4/src/main/java/plugins/materials/events/MaterialsProducerPropertyDefinitionEvent.java @@ -36,7 +36,7 @@ public MaterialsProducerPropertyDefinitionEvent(MaterialsProducerPropertyId mate /** * Returns the property id of the added property definition */ - public MaterialsProducerPropertyId getPersonPropertyId() { + public MaterialsProducerPropertyId getProducerPropertyId() { return materialsProducerPropertyId; } diff --git a/gcm4/src/main/java/plugins/materials/support/MaterialsProducerConstructionData.java b/gcm4/src/main/java/plugins/materials/support/MaterialsProducerConstructionData.java index a988f70ce..a3eb14ab9 100644 --- a/gcm4/src/main/java/plugins/materials/support/MaterialsProducerConstructionData.java +++ b/gcm4/src/main/java/plugins/materials/support/MaterialsProducerConstructionData.java @@ -36,6 +36,8 @@ public static Builder builder() { public static class Builder { private Data data = new Data(); + private Builder() {} + private void validate() { if (data.materialsProducerId == null) { throw new ContractException(MaterialsError.NULL_MATERIALS_PRODUCER_ID); diff --git a/gcm4/src/main/java/plugins/materials/testsupport/MaterialsActionSupport.java b/gcm4/src/main/java/plugins/materials/testsupport/MaterialsActionSupport.java index 6faa7cc5c..f5074e8e1 100644 --- a/gcm4/src/main/java/plugins/materials/testsupport/MaterialsActionSupport.java +++ b/gcm4/src/main/java/plugins/materials/testsupport/MaterialsActionSupport.java @@ -50,6 +50,8 @@ */ public class MaterialsActionSupport { + private MaterialsActionSupport(){} + /** * Creates an action plugin with an agent that will execute the given * consumer at time 0. The action plugin and the remaining arguments are diff --git a/gcm4/src/main/java/plugins/materials/testsupport/TestBatchConstructionInfo.java b/gcm4/src/main/java/plugins/materials/testsupport/TestBatchConstructionInfo.java index 02bfb951a..b134612b3 100644 --- a/gcm4/src/main/java/plugins/materials/testsupport/TestBatchConstructionInfo.java +++ b/gcm4/src/main/java/plugins/materials/testsupport/TestBatchConstructionInfo.java @@ -8,6 +8,8 @@ public class TestBatchConstructionInfo { + private TestBatchConstructionInfo(){} + public static BatchConstructionInfo getBatchConstructionInfo(MaterialsProducerId materialsProducerId, MaterialId materialId, double amount, RandomGenerator randomGenerator) { BatchConstructionInfo.Builder builder = // BatchConstructionInfo .builder()// diff --git a/gcm4/src/test/java/nucleus/AT_EventFilter.java b/gcm4/src/test/java/nucleus/AT_EventFilter.java index a568bfa03..29d781e87 100644 --- a/gcm4/src/test/java/nucleus/AT_EventFilter.java +++ b/gcm4/src/test/java/nucleus/AT_EventFilter.java @@ -95,7 +95,7 @@ public void testGetFunctionValuePairs() { .addFunctionValuePair(xFunction, 2)// .build(); functionValuePairs = eventFilter.getFunctionValuePairs(); - expectedFunctionValuePairs.add(new Pair, Object>(xFunction, 2)); + expectedFunctionValuePairs.add(new Pair<>(xFunction, 2)); assertNotNull(functionValuePairs); assertEquals(expectedFunctionValuePairs, functionValuePairs); @@ -110,7 +110,7 @@ public void testGetFunctionValuePairs() { .addFunctionValuePair(yFunction, 3.0)// .build(); functionValuePairs = eventFilter.getFunctionValuePairs(); - expectedFunctionValuePairs.add(new Pair, Object>(yFunction, 3.0)); + expectedFunctionValuePairs.add(new Pair<>(yFunction, 3.0)); assertNotNull(functionValuePairs); assertEquals(expectedFunctionValuePairs, functionValuePairs); diff --git a/gcm4/src/test/java/plugins/groups/support/AT_GroupPropertyDefinitionInitialization.java b/gcm4/src/test/java/plugins/groups/support/AT_GroupPropertyDefinitionInitialization.java index aef473953..dc3b7db98 100644 --- a/gcm4/src/test/java/plugins/groups/support/AT_GroupPropertyDefinitionInitialization.java +++ b/gcm4/src/test/java/plugins/groups/support/AT_GroupPropertyDefinitionInitialization.java @@ -123,7 +123,7 @@ public void testGetPropertyValues() { GroupId groupId = new GroupId(10000 + i); for (int j = 0; j < 3; j++) { String value = Integer.toString(randomGenerator.nextInt(100)); - Pair propertyValue = new Pair(groupId, value); + Pair propertyValue = new Pair<>(groupId, value); expectedListOfPropertyValues.add(propertyValue); definitionInitializationBuilder.addPropertyValue(groupId, value); } @@ -328,7 +328,7 @@ public void testAddPropertyValue() { GroupId groupId = new GroupId(10000 + i); for (int j = 0; j < 3; j++) { String value = Integer.toString(randomGenerator.nextInt(100)); - Pair propertyValue = new Pair(groupId, value); + Pair propertyValue = new Pair<>(groupId, value); expectedListOfPropertyValues.add(propertyValue); definitionInitializationBuilder.addPropertyValue(groupId, value); } diff --git a/gcm4/src/test/java/plugins/materials/actors/AT_BatchStatusReport.java b/gcm4/src/test/java/plugins/materials/actors/AT_BatchStatusReport.java index 6b3bf6e06..86daf7e2d 100644 --- a/gcm4/src/test/java/plugins/materials/actors/AT_BatchStatusReport.java +++ b/gcm4/src/test/java/plugins/materials/actors/AT_BatchStatusReport.java @@ -1,6 +1,7 @@ package plugins.materials.actors; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.util.ArrayList; import java.util.Collections; @@ -36,7 +37,9 @@ import plugins.reports.support.ReportItem.Builder; import plugins.reports.support.SimpleReportId; import plugins.stochastics.StochasticsDataManager; +import tools.annotations.UnitTag; import tools.annotations.UnitTest; +import tools.annotations.UnitTestConstructor; import tools.annotations.UnitTestMethod; @UnitTest(target = BatchStatusReport.class) @@ -54,16 +57,15 @@ private ReportItem getReportItemFromBatch(ActorContext agentContext, BatchId bat stageString = optionalStageId.get().toString(); } - List elements = new ArrayList<>(); - + List elements = new ArrayList<>(); + elements.add(agentContext.getTime()); elements.add(batchId); elements.add(batchProducer); elements.add(stageString); elements.add(batchMaterialId); elements.add(amount); - - + for (MaterialId materialId : materialsDataManager.getMaterialIds()) { boolean matchingMaterial = batchMaterialId.equals(materialId); Set batchPropertyIds = materialsDataManager.getBatchPropertyIds(materialId); @@ -75,15 +77,22 @@ private ReportItem getReportItemFromBatch(ActorContext agentContext, BatchId bat } } } - + ReportItem reportItem = getReportItem(elements); - - + return reportItem; } @Test - @UnitTestMethod(name = "init", args = {ActorContext.class}) + @UnitTestConstructor(args = { ReportId.class }) + public void testConstructor() { + BatchStatusReport report = new BatchStatusReport(REPORT_ID); + + assertNotNull(report); + } + + @Test + @UnitTestMethod(name = "init", args = { ActorContext.class }, tags = { UnitTag.INCOMPLETE }) public void testInit() { Set expectedReportItems = new LinkedHashSet<>(); @@ -103,7 +112,8 @@ public void testInit() { for (int i = 0; i < 20; i++) { TestMaterialId materialId = TestMaterialId.getRandomMaterialId(randomGenerator); double amount = randomGenerator.nextDouble(); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(testMaterialsProducerId, materialId, amount, randomGenerator); + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo + .getBatchConstructionInfo(testMaterialsProducerId, materialId, amount, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); expectedReportItems.add(getReportItemFromBatch(c, batchId)); } @@ -118,7 +128,8 @@ public void testInit() { RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); for (TestMaterialId testMaterialId : TestMaterialId.values()) { - List batches = materialsDataManager.getInventoryBatchesByMaterialId(testMaterialsProducerId, testMaterialId); + List batches = materialsDataManager + .getInventoryBatchesByMaterialId(testMaterialsProducerId, testMaterialId); if (batches.size() > 1) { for (int i = 0; i < batches.size(); i++) { @@ -166,7 +177,8 @@ public void testInit() { for (BatchId batchId : inventoryBatches) { TestMaterialId materialId = materialsDataManager.getBatchMaterial(batchId); - TestBatchPropertyId propertyId = TestBatchPropertyId.getRandomMutableBatchPropertyId(materialId, randomGenerator); + TestBatchPropertyId propertyId = TestBatchPropertyId.getRandomMutableBatchPropertyId(materialId, + randomGenerator); Object value = propertyId.getRandomPropertyValue(randomGenerator); materialsDataManager.setBatchPropertyValue(batchId, propertyId, value); expectedReportItems.add(getReportItemFromBatch(c, batchId)); @@ -219,17 +231,17 @@ public void testInit() { TestPluginData testPluginData = pluginBuilder.build(); Plugin testPlugin = TestPlugin.getTestPlugin(testPluginData); - //Set actualReportItems = MaterialsActionSupport.testConsumers(8914112012010329946L, testPlugin, new BatchStatusReport(REPORT_ID)::init); - Set actualReportItems = MaterialsActionSupport.testConsumers(2819236410498978100L, testPlugin, new BatchStatusReport(REPORT_ID)::init); - + // Set actualReportItems = + // MaterialsActionSupport.testConsumers(8914112012010329946L, testPlugin, new + // BatchStatusReport(REPORT_ID)::init); + Set actualReportItems = MaterialsActionSupport.testConsumers(2819236410498978100L, testPlugin, + new BatchStatusReport(REPORT_ID)::init); assertEquals(expectedReportItems, actualReportItems); } private static ReportItem getReportItem(List values) { - Builder builder = ReportItem.builder(); - builder.setReportId(REPORT_ID); - builder.setReportHeader(REPORT_HEADER); + Builder builder = ReportItem.builder().setReportId(REPORT_ID).setReportHeader(REPORT_HEADER); for (Object value : values) { builder.addValue(value); } @@ -242,16 +254,17 @@ private static ReportItem getReportItem(List values) { private static ReportHeader getReportHeader() { - ReportHeader.Builder builder = ReportHeader .builder()// - .add("time")// - .add("batch")// - .add("materials_producer")// - .add("stage")// - .add("material")// - .add("amount");// + ReportHeader.Builder builder = ReportHeader.builder()// + .add("time")// + .add("batch")// + .add("materials_producer")// + .add("stage")// + .add("material")// + .add("amount");// for (TestMaterialId testMaterialId : TestMaterialId.values()) { - for (TestBatchPropertyId testBatchPropertyId : TestBatchPropertyId.getTestBatchPropertyIds(testMaterialId)) { + for (TestBatchPropertyId testBatchPropertyId : TestBatchPropertyId + .getTestBatchPropertyIds(testMaterialId)) { builder.add(testMaterialId + "." + testBatchPropertyId); } } diff --git a/gcm4/src/test/java/plugins/materials/actors/AT_MaterialsProducerPropertyReport.java b/gcm4/src/test/java/plugins/materials/actors/AT_MaterialsProducerPropertyReport.java index f620ed31e..bf49cbdb8 100644 --- a/gcm4/src/test/java/plugins/materials/actors/AT_MaterialsProducerPropertyReport.java +++ b/gcm4/src/test/java/plugins/materials/actors/AT_MaterialsProducerPropertyReport.java @@ -1,6 +1,7 @@ package plugins.materials.actors; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.util.ArrayList; import java.util.LinkedHashSet; @@ -28,16 +29,20 @@ import plugins.reports.support.ReportItem.Builder; import plugins.reports.support.SimpleReportId; import plugins.stochastics.StochasticsDataManager; +import tools.annotations.UnitTag; import tools.annotations.UnitTest; +import tools.annotations.UnitTestConstructor; import tools.annotations.UnitTestMethod; @UnitTest(target = MaterialsProducerPropertyReport.class) public final class AT_MaterialsProducerPropertyReport { - private ReportItem getReportItemFromPropertyId(ActorContext agentContext, MaterialsProducerId materialsProducerId, MaterialsProducerPropertyId materialsProducerPropertyId) { + private ReportItem getReportItemFromPropertyId(ActorContext agentContext, MaterialsProducerId materialsProducerId, + MaterialsProducerPropertyId materialsProducerPropertyId) { MaterialsDataManager materialsDataManager = agentContext.getDataManager(MaterialsDataManager.class); - Object propertyValue = materialsDataManager.getMaterialsProducerPropertyValue(materialsProducerId, materialsProducerPropertyId); + Object propertyValue = materialsDataManager.getMaterialsProducerPropertyValue(materialsProducerId, + materialsProducerPropertyId); ReportItem reportItem = getReportItem(// agentContext.getTime(), // @@ -50,7 +55,15 @@ private ReportItem getReportItemFromPropertyId(ActorContext agentContext, Materi } @Test - @UnitTestMethod(name = "init", args = {ActorContext.class}) + @UnitTestConstructor(args = { ReportId.class }) + public void testConstructor() { + MaterialsProducerPropertyReport report = new MaterialsProducerPropertyReport(REPORT_ID); + + assertNotNull(report); + } + + @Test + @UnitTestMethod(name = "init", args = { ActorContext.class }, tags = { UnitTag.INCOMPLETE }) public void testInit() { Set expectedReportItems = new LinkedHashSet<>(); @@ -62,29 +75,34 @@ public void testInit() { pluginBuilder.addTestActorPlan("actor", new TestActorPlan(actionTime++, (c) -> { for (TestMaterialsProducerId testMaterialsProducerId : TestMaterialsProducerId.values()) { - for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId.values()) { - expectedReportItems.add(getReportItemFromPropertyId(c, testMaterialsProducerId, testMaterialsProducerPropertyId)); + for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId + .values()) { + expectedReportItems.add( + getReportItemFromPropertyId(c, testMaterialsProducerId, testMaterialsProducerPropertyId)); } } })); - //add a new materials producer at time 30 + // add a new materials producer at time 30 pluginBuilder.addTestActorPlan("actor", new TestActorPlan(30, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsProducerConstructionData.Builder builder = MaterialsProducerConstructionData.builder(); - + builder.setMaterialsProducerId(newMaterialsProducerId); - for(TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId.getPropertiesWithoutDefaultValues()) { + for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId + .getPropertiesWithoutDefaultValues()) { Object randomPropertyValue = testMaterialsProducerPropertyId.getRandomPropertyValue(randomGenerator); builder.setMaterialsProducerPropertyValue(testMaterialsProducerPropertyId, randomPropertyValue); } - + MaterialsProducerConstructionData materialsProducerConstructionData = builder.build(); materialsDataManager.addMaterialsProducer(materialsProducerConstructionData); - for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId.values()) { - expectedReportItems.add(getReportItemFromPropertyId(c, newMaterialsProducerId, testMaterialsProducerPropertyId)); + for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId + .values()) { + expectedReportItems + .add(getReportItemFromPropertyId(c, newMaterialsProducerId, testMaterialsProducerPropertyId)); } })); @@ -93,14 +111,19 @@ public void testInit() { // set a property value pluginBuilder.addTestActorPlan("actor", new TestActorPlan(actionTime++, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - List materialsProducerIds = new ArrayList<>(materialsDataManager.getMaterialsProducerIds()); + List materialsProducerIds = new ArrayList<>( + materialsDataManager.getMaterialsProducerIds()); StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); - MaterialsProducerId materialsProducerId = materialsProducerIds.get(randomGenerator.nextInt(materialsProducerIds.size())); - TestMaterialsProducerPropertyId testMaterialsProducerPropertyId = TestMaterialsProducerPropertyId.getRandomMutableMaterialsProducerPropertyId(randomGenerator); + MaterialsProducerId materialsProducerId = materialsProducerIds + .get(randomGenerator.nextInt(materialsProducerIds.size())); + TestMaterialsProducerPropertyId testMaterialsProducerPropertyId = TestMaterialsProducerPropertyId + .getRandomMutableMaterialsProducerPropertyId(randomGenerator); Object propertyValue = testMaterialsProducerPropertyId.getRandomPropertyValue(randomGenerator); - materialsDataManager.setMaterialsProducerPropertyValue(materialsProducerId, testMaterialsProducerPropertyId, propertyValue); - expectedReportItems.add(getReportItemFromPropertyId(c, materialsProducerId, testMaterialsProducerPropertyId)); + materialsDataManager.setMaterialsProducerPropertyValue(materialsProducerId, + testMaterialsProducerPropertyId, propertyValue); + expectedReportItems + .add(getReportItemFromPropertyId(c, materialsProducerId, testMaterialsProducerPropertyId)); })); @@ -108,15 +131,14 @@ public void testInit() { TestPluginData testPluginData = pluginBuilder.build(); Plugin testPlugin = TestPlugin.getTestPlugin(testPluginData); - Set actualReportItems = MaterialsActionSupport.testConsumers(8759226038479000135L, testPlugin, new MaterialsProducerPropertyReport(REPORT_ID)::init); + Set actualReportItems = MaterialsActionSupport.testConsumers(8759226038479000135L, testPlugin, + new MaterialsProducerPropertyReport(REPORT_ID)::init); assertEquals(expectedReportItems, actualReportItems); } private static ReportItem getReportItem(Object... values) { - Builder builder = ReportItem.builder(); - builder.setReportId(REPORT_ID); - builder.setReportHeader(REPORT_HEADER); + Builder builder = ReportItem.builder().setReportId(REPORT_ID).setReportHeader(REPORT_HEADER); for (Object value : values) { builder.addValue(value); } @@ -128,11 +150,11 @@ private static ReportItem getReportItem(Object... values) { private static final ReportHeader REPORT_HEADER = getReportHeader(); private static ReportHeader getReportHeader() { - ReportHeader.Builder builder = ReportHeader .builder()// - .add("time")// - .add("materials_producer")// - .add("property")// - .add("value");// + ReportHeader.Builder builder = ReportHeader.builder()// + .add("time")// + .add("materials_producer")// + .add("property")// + .add("value");// return builder.build(); } diff --git a/gcm4/src/test/java/plugins/materials/actors/AT_MaterialsProducerResourceReport.java b/gcm4/src/test/java/plugins/materials/actors/AT_MaterialsProducerResourceReport.java index 25de6dd9f..9114b0080 100644 --- a/gcm4/src/test/java/plugins/materials/actors/AT_MaterialsProducerResourceReport.java +++ b/gcm4/src/test/java/plugins/materials/actors/AT_MaterialsProducerResourceReport.java @@ -1,6 +1,7 @@ package plugins.materials.actors; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.util.ArrayList; import java.util.LinkedHashSet; @@ -35,13 +36,16 @@ import plugins.resources.testsupport.TestResourceId; import plugins.stochastics.StochasticsDataManager; import plugins.util.properties.TimeTrackingPolicy; +import tools.annotations.UnitTag; import tools.annotations.UnitTest; +import tools.annotations.UnitTestConstructor; import tools.annotations.UnitTestMethod; @UnitTest(target = MaterialsProducerResourceReport.class) public final class AT_MaterialsProducerResourceReport { - private ReportItem getReportItemFromResourceId(ActorContext agentContext, MaterialsProducerId materialsProducerId, ResourceId resourceId, long amount) { + private ReportItem getReportItemFromResourceId(ActorContext agentContext, MaterialsProducerId materialsProducerId, + ResourceId resourceId, long amount) { String actionName; if (amount < 0) { @@ -57,19 +61,27 @@ private ReportItem getReportItemFromResourceId(ActorContext agentContext, Materi } @Test - @UnitTestMethod(name = "init", args = {ActorContext.class}) + @UnitTestConstructor(args = { ReportId.class }) + public void testConstructor() { + MaterialsProducerResourceReport report = new MaterialsProducerResourceReport(REPORT_ID); + assertNotNull(report); + } + + @Test + @UnitTestMethod(name = "init", args = { ActorContext.class }, tags = { UnitTag.INCOMPLETE }) public void testInit() { Set expectedReportItems = new LinkedHashSet<>(); TestPluginData.Builder pluginBuilder = TestPluginData.builder(); MaterialsProducerId newMaterialsProducerId = TestMaterialsProducerId.getUnknownMaterialsProducerId(); - + double actionTime = 0; pluginBuilder.addTestActorPlan("actor", new TestActorPlan(actionTime++, (c) -> { for (TestMaterialsProducerId testMaterialsProducerId : TestMaterialsProducerId.values()) { for (TestResourceId testResourceId : TestResourceId.values()) { - expectedReportItems.add(getReportItemFromResourceId(c, testMaterialsProducerId, testResourceId, 0L)); + expectedReportItems + .add(getReportItemFromResourceId(c, testMaterialsProducerId, testResourceId, 0L)); } } @@ -83,21 +95,22 @@ public void testInit() { })); - //add a new materials producer just before time 20 + // add a new materials producer just before time 20 pluginBuilder.addTestActorPlan("actor", new TestActorPlan(19.5, (c) -> { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); MaterialsProducerConstructionData.Builder builder = // MaterialsProducerConstructionData.builder()// - .setMaterialsProducerId(newMaterialsProducerId);// - for(TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId.getPropertiesWithoutDefaultValues()) { + .setMaterialsProducerId(newMaterialsProducerId);// + for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId + .getPropertiesWithoutDefaultValues()) { Object randomPropertyValue = testMaterialsProducerPropertyId.getRandomPropertyValue(randomGenerator); builder.setMaterialsProducerPropertyValue(testMaterialsProducerPropertyId, randomPropertyValue); - } - + } + MaterialsProducerConstructionData materialsProducerConstructionData = builder.build(); - + materialsDataManager.addMaterialsProducer(materialsProducerConstructionData); ResourcesDataManager resourcesDataManager = c.getDataManager(ResourcesDataManager.class); for (ResourceId resourceId : resourcesDataManager.getResourceIds()) { @@ -106,22 +119,20 @@ public void testInit() { })); - - for (int i = 0; i < 100; i++) { // set a resource value pluginBuilder.addTestActorPlan("actor", new TestActorPlan(actionTime++, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); List mats = new ArrayList<>(materialsDataManager.getMaterialsProducerIds()); - + StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsProducerId materialsProducerId = mats.get(randomGenerator.nextInt(mats.size())); ResourcesDataManager resourcesDataManager = c.getDataManager(ResourcesDataManager.class); List resourceIds = new ArrayList<>(resourcesDataManager.getResourceIds()); Random random = new Random(randomGenerator.nextLong()); - + ResourceId resourceId = resourceIds.get(random.nextInt(resourceIds.size())); if (randomGenerator.nextBoolean()) { @@ -130,12 +141,15 @@ public void testInit() { materialsDataManager.convertStageToResource(stageId, resourceId, amount); expectedReportItems.add(getReportItemFromResourceId(c, materialsProducerId, resourceId, amount)); } else { - long resourceLevel = materialsDataManager.getMaterialsProducerResourceLevel(materialsProducerId, resourceId); + long resourceLevel = materialsDataManager.getMaterialsProducerResourceLevel(materialsProducerId, + resourceId); if (resourceLevel > 0) { long amount = randomGenerator.nextInt((int) resourceLevel) + 1; TestRegionId testRegionId = TestRegionId.getRandomRegionId(randomGenerator); - materialsDataManager.transferResourceToRegion(materialsProducerId, resourceId, testRegionId, amount); - expectedReportItems.add(getReportItemFromResourceId(c, materialsProducerId, resourceId, -amount)); + materialsDataManager.transferResourceToRegion(materialsProducerId, resourceId, testRegionId, + amount); + expectedReportItems + .add(getReportItemFromResourceId(c, materialsProducerId, resourceId, -amount)); } } })); @@ -143,15 +157,14 @@ public void testInit() { TestPluginData testPluginData = pluginBuilder.build(); Plugin testPlugin = TestPlugin.getTestPlugin(testPluginData); - Set actualReportItems = MaterialsActionSupport.testConsumers(6081341958178733565L, testPlugin, new MaterialsProducerResourceReport(REPORT_ID)::init); + Set actualReportItems = MaterialsActionSupport.testConsumers(6081341958178733565L, testPlugin, + new MaterialsProducerResourceReport(REPORT_ID)::init); assertEquals(expectedReportItems, actualReportItems); } private static ReportItem getReportItem(Object... values) { - Builder builder = ReportItem.builder(); - builder.setReportId(REPORT_ID); - builder.setReportHeader(REPORT_HEADER); + Builder builder = ReportItem.builder().setReportId(REPORT_ID).setReportHeader(REPORT_HEADER); for (Object value : values) { builder.addValue(value); } @@ -163,13 +176,13 @@ private static ReportItem getReportItem(Object... values) { private static final ReportHeader REPORT_HEADER = getReportHeader(); private static ReportHeader getReportHeader() { - return ReportHeader .builder()// - .add("time")// - .add("resource")// - .add("materials_producer")// - .add("action")// - .add("amount")// - .build(); + return ReportHeader.builder()// + .add("time")// + .add("resource")// + .add("materials_producer")// + .add("action")// + .add("amount")// + .build(); } diff --git a/gcm4/src/test/java/plugins/materials/actors/AT_StageReport.java b/gcm4/src/test/java/plugins/materials/actors/AT_StageReport.java index cad747730..df17d9716 100644 --- a/gcm4/src/test/java/plugins/materials/actors/AT_StageReport.java +++ b/gcm4/src/test/java/plugins/materials/actors/AT_StageReport.java @@ -1,6 +1,7 @@ package plugins.materials.actors; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.util.ArrayList; import java.util.LinkedHashSet; @@ -25,7 +26,9 @@ import plugins.reports.support.ReportItem; import plugins.reports.support.SimpleReportId; import plugins.stochastics.StochasticsDataManager; +import tools.annotations.UnitTag; import tools.annotations.UnitTest; +import tools.annotations.UnitTestConstructor; import tools.annotations.UnitTestMethod; import util.random.RandomGeneratorProvider; @@ -48,21 +51,29 @@ private Action(final String displayName) { } } - private ReportItem getReportItem(ActorContext agentContext, StageId stageId, MaterialsProducerId materialsProducerId, boolean isOffered, Action action) { - - return ReportItem .builder()// - .setReportId(REPORT_ID)// - .setReportHeader(REPORT_HEADER)// - .addValue(agentContext.getTime())// - .addValue(stageId)// - .addValue(materialsProducerId)// - .addValue(action.displayName)// - .addValue(isOffered)// - .build();// + private ReportItem getReportItem(ActorContext agentContext, StageId stageId, + MaterialsProducerId materialsProducerId, boolean isOffered, Action action) { + + return ReportItem.builder()// + .setReportId(REPORT_ID)// + .setReportHeader(REPORT_HEADER)// + .addValue(agentContext.getTime())// + .addValue(stageId)// + .addValue(materialsProducerId)// + .addValue(action.displayName)// + .addValue(isOffered)// + .build();// } @Test - @UnitTestMethod(name = "init", args = {ActorContext.class}) + @UnitTestConstructor(args = { ReportId.class }) + public void testConstructor() { + StageReport report = new StageReport(REPORT_ID); + assertNotNull(report); + } + + @Test + @UnitTestMethod(name = "init", args = { ActorContext.class }, tags = { UnitTag.INCOMPLETE }) public void testInit() { /* * Create containers for the expected and actual report items that will @@ -134,40 +145,45 @@ public void testInit() { action = Action.OFFERED; } } - + StageId stageId; boolean stageOffered; switch (action) { - case CREATED: - stageId = materialsDataManager.addStage(testMaterialsProducerId); - stageOffered = materialsDataManager.isStageOffered(stageId); - expectedReportItems.add(getReportItem(c, stageId, testMaterialsProducerId, stageOffered, action)); - break; - case DESTROYED: - stages.removeAll(offeredStages); - stageId = stages.get(randomGenerator.nextInt(stages.size())); - stageOffered = materialsDataManager.isStageOffered(stageId); - materialsDataManager.removeStage(stageId, false); - expectedReportItems.add(getReportItem(c, stageId, testMaterialsProducerId, stageOffered, action)); - break; - case OFFERED: - stageId = stages.get(randomGenerator.nextInt(stages.size())); - stageOffered = materialsDataManager.isStageOffered(stageId); - materialsDataManager.setStageOfferState(stageId, !stageOffered); - expectedReportItems.add(getReportItem(c, stageId, testMaterialsProducerId, !stageOffered, action)); - break; - case TRANSFERRED: - stageId = offeredStages.get(randomGenerator.nextInt(offeredStages.size())); - stageOffered = materialsDataManager.isStageOffered(stageId); - List candidateProducerIds = new ArrayList<>(materialsDataManager.getMaterialsProducerIds()); - candidateProducerIds.remove(testMaterialsProducerId); - MaterialsProducerId materialsProducerId = candidateProducerIds.get(randomGenerator.nextInt(candidateProducerIds.size())); - materialsDataManager.transferOfferedStage(stageId, materialsProducerId); - expectedReportItems.add(getReportItem(c, stageId, materialsProducerId, true, action)); - expectedReportItems.add(getReportItem(c, stageId, materialsProducerId, false, Action.OFFERED)); - break; - default: - throw new RuntimeException("unhandled action type"); + case CREATED: + stageId = materialsDataManager.addStage(testMaterialsProducerId); + stageOffered = materialsDataManager.isStageOffered(stageId); + expectedReportItems + .add(getReportItem(c, stageId, testMaterialsProducerId, stageOffered, action)); + break; + case DESTROYED: + stages.removeAll(offeredStages); + stageId = stages.get(randomGenerator.nextInt(stages.size())); + stageOffered = materialsDataManager.isStageOffered(stageId); + materialsDataManager.removeStage(stageId, false); + expectedReportItems + .add(getReportItem(c, stageId, testMaterialsProducerId, stageOffered, action)); + break; + case OFFERED: + stageId = stages.get(randomGenerator.nextInt(stages.size())); + stageOffered = materialsDataManager.isStageOffered(stageId); + materialsDataManager.setStageOfferState(stageId, !stageOffered); + expectedReportItems + .add(getReportItem(c, stageId, testMaterialsProducerId, !stageOffered, action)); + break; + case TRANSFERRED: + stageId = offeredStages.get(randomGenerator.nextInt(offeredStages.size())); + stageOffered = materialsDataManager.isStageOffered(stageId); + List candidateProducerIds = new ArrayList<>( + materialsDataManager.getMaterialsProducerIds()); + candidateProducerIds.remove(testMaterialsProducerId); + MaterialsProducerId materialsProducerId = candidateProducerIds + .get(randomGenerator.nextInt(candidateProducerIds.size())); + materialsDataManager.transferOfferedStage(stageId, materialsProducerId); + expectedReportItems.add(getReportItem(c, stageId, materialsProducerId, true, action)); + expectedReportItems.add(getReportItem(c, stageId, materialsProducerId, false, Action.OFFERED)); + break; + default: + throw new RuntimeException("unhandled action type"); } })); @@ -175,7 +191,8 @@ public void testInit() { TestPluginData testPluginData = pluginBuilder.build(); Plugin testPlugin = TestPlugin.getTestPlugin(testPluginData); - Set actualReportItems = MaterialsActionSupport.testConsumers(542686524159732447L, testPlugin, new StageReport(REPORT_ID)::init); + Set actualReportItems = MaterialsActionSupport.testConsumers(542686524159732447L, testPlugin, + new StageReport(REPORT_ID)::init); assertEquals(expectedReportItems, actualReportItems); } @@ -185,13 +202,13 @@ public void testInit() { private static final ReportHeader REPORT_HEADER = getReportHeader(); private static ReportHeader getReportHeader() { - return ReportHeader .builder()// - .add("time")// - .add("stage")// - .add("materials_producer")// - .add("action")// - .add("offered")// - .build(); + return ReportHeader.builder()// + .add("time")// + .add("stage")// + .add("materials_producer")// + .add("action")// + .add("offered")// + .build(); } diff --git a/gcm4/src/test/java/plugins/materials/datamanagers/AT_MaterialsDataManager.java b/gcm4/src/test/java/plugins/materials/datamanagers/AT_MaterialsDataManager.java index d19b1efbd..318b8ecd4 100644 --- a/gcm4/src/test/java/plugins/materials/datamanagers/AT_MaterialsDataManager.java +++ b/gcm4/src/test/java/plugins/materials/datamanagers/AT_MaterialsDataManager.java @@ -104,7 +104,8 @@ public class AT_MaterialsDataManager { @Test @UnitTestConstructor(args = { MaterialsPluginData.class }) public void testConstructor() { - ContractException contractException = assertThrows(ContractException.class, () -> new MaterialsDataManager(null)); + ContractException contractException = assertThrows(ContractException.class, + () -> new MaterialsDataManager(null)); assertEquals(MaterialsError.NULL_MATERIALS_PLUGIN_DATA, contractException.getErrorType()); } @@ -139,8 +140,10 @@ public void testAddBatch() { builder.setMaterialId(testMaterialId); double amount = randomGenerator.nextDouble(); builder.setAmount(amount);// - for (TestBatchPropertyId testBatchPropertyId : TestBatchPropertyId.getTestBatchPropertyIds(testMaterialId)) { - builder.setPropertyValue(testBatchPropertyId, testBatchPropertyId.getRandomPropertyValue(randomGenerator)); + for (TestBatchPropertyId testBatchPropertyId : TestBatchPropertyId + .getTestBatchPropertyIds(testMaterialId)) { + builder.setPropertyValue(testBatchPropertyId, + testBatchPropertyId.getRandomPropertyValue(randomGenerator)); } BatchConstructionInfo batchConstructionInfo = builder.build();// @@ -401,14 +404,16 @@ public void testAddStage() { /* precondition test if the materials producer is null */ MaterialsActionSupport.testConsumer(2938510662832987631L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.addStage(null)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.addStage(null)); assertEquals(MaterialsError.NULL_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); /* precondition test if the materials producer is unknown */ MaterialsActionSupport.testConsumer(3333157817809403586L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.addStage(TestMaterialsProducerId.getUnknownMaterialsProducerId())); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.addStage(TestMaterialsProducerId.getUnknownMaterialsProducerId())); assertEquals(MaterialsError.UNKNOWN_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); @@ -437,7 +442,8 @@ public void testBatchExists() { for (TestMaterialId testMaterialId : TestMaterialId.values()) { double value = randomGenerator.nextDouble() * 100; // add the batch an show it exists - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(testMaterialsProducerId, testMaterialId, value, randomGenerator); + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo + .getBatchConstructionInfo(testMaterialsProducerId, testMaterialId, value, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); assertTrue(materialsDataManager.batchExists(batchId)); // remove the batch and show that it still exists @@ -485,7 +491,8 @@ public void testBatchPropertyIdExists() { } assertFalse(materialsDataManager.batchPropertyIdExists(TestMaterialId.MATERIAL_1, null)); - assertFalse(materialsDataManager.batchPropertyIdExists(null, TestBatchPropertyId.BATCH_PROPERTY_1_1_BOOLEAN_IMMUTABLE_NO_TRACK)); + assertFalse(materialsDataManager.batchPropertyIdExists(null, + TestBatchPropertyId.BATCH_PROPERTY_1_1_BOOLEAN_IMMUTABLE_NO_TRACK)); assertFalse(materialsDataManager.batchPropertyIdExists(null, null)); // precondition tests : none @@ -540,7 +547,8 @@ public void testConvertStageToBatch() { for (int j = 0; j < batchCount; j++) { materialId = TestMaterialId.getRandomMaterialId(randomGenerator); amount = randomGenerator.nextDouble() + 0.01; - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(testMaterialsProducerId, materialId, amount, randomGenerator); + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo + .getBatchConstructionInfo(testMaterialsProducerId, materialId, amount, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); materialsDataManager.moveBatchToStage(batchId, stageId); } @@ -593,7 +601,8 @@ public void testConvertStageToBatch() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); double amount = 12.5; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.convertStageToBatch(stageId, null, amount)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.convertStageToBatch(stageId, null, amount)); assertEquals(MaterialsError.NULL_MATERIAL_ID, contractException.getErrorType()); }); @@ -602,7 +611,8 @@ public void testConvertStageToBatch() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); double amount = 12.5; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.convertStageToBatch(stageId, TestMaterialId.getUnknownMaterialId(), amount)); + ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager + .convertStageToBatch(stageId, TestMaterialId.getUnknownMaterialId(), amount)); assertEquals(MaterialsError.UNKNOWN_MATERIAL_ID, contractException.getErrorType()); }); @@ -612,7 +622,8 @@ public void testConvertStageToBatch() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); MaterialId materialId = TestMaterialId.MATERIAL_1; double amount = 12.5; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.convertStageToBatch(null, materialId, amount)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.convertStageToBatch(null, materialId, amount)); assertEquals(MaterialsError.NULL_STAGE_ID, contractException.getErrorType()); }); @@ -622,7 +633,8 @@ public void testConvertStageToBatch() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); MaterialId materialId = TestMaterialId.MATERIAL_1; double amount = 12.5; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.convertStageToBatch(new StageId(10000000), materialId, amount)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.convertStageToBatch(new StageId(10000000), materialId, amount)); assertEquals(MaterialsError.UNKNOWN_STAGE_ID, contractException.getErrorType()); }); @@ -633,7 +645,8 @@ public void testConvertStageToBatch() { MaterialId materialId = TestMaterialId.MATERIAL_1; double amount = 12.5; materialsDataManager.setStageOfferState(stageId, true); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.convertStageToBatch(stageId, materialId, amount)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.convertStageToBatch(stageId, materialId, amount)); assertEquals(MaterialsError.OFFERED_STAGE_UNALTERABLE, contractException.getErrorType()); }); @@ -642,7 +655,8 @@ public void testConvertStageToBatch() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); MaterialId materialId = TestMaterialId.MATERIAL_1; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.convertStageToBatch(stageId, materialId, Double.POSITIVE_INFINITY)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.convertStageToBatch(stageId, materialId, Double.POSITIVE_INFINITY)); assertEquals(MaterialsError.NON_FINITE_MATERIAL_AMOUNT, contractException.getErrorType()); }); @@ -651,7 +665,8 @@ public void testConvertStageToBatch() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); MaterialId materialId = TestMaterialId.MATERIAL_1; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.convertStageToBatch(stageId, materialId, -1.0)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.convertStageToBatch(stageId, materialId, -1.0)); assertEquals(MaterialsError.NEGATIVE_MATERIAL_AMOUNT, contractException.getErrorType()); }); @@ -679,9 +694,11 @@ public void testStageToResourceConversionEvent() { }); for (TestResourceId testResourceId : TestResourceId.values()) { - EventFilter eventFilter = materialsDataManager.getEventFilterForMaterialsProducerResourceUpdateEvent(testResourceId); + EventFilter eventFilter = materialsDataManager + .getEventFilterForMaterialsProducerResourceUpdateEvent(testResourceId); c.subscribe(eventFilter, (c2, e) -> { - actualObservations.add(new MultiKey(c2.getTime(), e.getMaterialsProducerId(), e.getResourceId(), e.getPreviousResourceLevel(), e.getCurrentResourceLevel())); + actualObservations.add(new MultiKey(c2.getTime(), e.getMaterialsProducerId(), e.getResourceId(), + e.getPreviousResourceLevel(), e.getCurrentResourceLevel())); }); } @@ -710,14 +727,16 @@ public void testStageToResourceConversionEvent() { for (int j = 0; j < batchCount; j++) { materialId = TestMaterialId.getRandomMaterialId(randomGenerator); amount = randomGenerator.nextDouble() + 0.01; - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(testMaterialsProducerId, materialId, amount, randomGenerator); + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo + .getBatchConstructionInfo(testMaterialsProducerId, materialId, amount, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); materialsDataManager.moveBatchToStage(batchId, stageId); } ResourceId resourceId = TestResourceId.getRandomResourceId(randomGenerator); long resourceAmount = randomGenerator.nextInt(100) + 1; - long previousResourceLevel = materialsDataManager.getMaterialsProducerResourceLevel(testMaterialsProducerId, resourceId); + long previousResourceLevel = materialsDataManager + .getMaterialsProducerResourceLevel(testMaterialsProducerId, resourceId); long expectedResourceLevel = previousResourceLevel + resourceAmount; List stageBatches = materialsDataManager.getStageBatches(stageId); materialsDataManager.convertStageToResource(stageId, resourceId, resourceAmount); @@ -728,14 +747,16 @@ public void testStageToResourceConversionEvent() { batchesToConfirm.addAll(stageBatches); // show that the stage was properly converted - long currentResourceLevel = materialsDataManager.getMaterialsProducerResourceLevel(testMaterialsProducerId, resourceId); + long currentResourceLevel = materialsDataManager + .getMaterialsProducerResourceLevel(testMaterialsProducerId, resourceId); assertEquals(expectedResourceLevel, currentResourceLevel); // generate the expected observations for (BatchId batchId : stageBatches) { expectedObservations.add(new MultiKey(c.getTime(), batchId)); } - expectedObservations.add(new MultiKey(c.getTime(), testMaterialsProducerId, resourceId, previousResourceLevel, currentResourceLevel)); + expectedObservations.add(new MultiKey(c.getTime(), testMaterialsProducerId, resourceId, + previousResourceLevel, currentResourceLevel)); expectedObservations.add(new MultiKey(c.getTime(), stageId)); } })); @@ -768,7 +789,8 @@ public void testStageToResourceConversionEvent() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); long amount = 15L; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.convertStageToResource(stageId, null, amount)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.convertStageToResource(stageId, null, amount)); assertEquals(ResourceError.NULL_RESOURCE_ID, contractException.getErrorType()); }); @@ -777,7 +799,8 @@ public void testStageToResourceConversionEvent() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); long amount = 15L; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.convertStageToResource(stageId, TestResourceId.getUnknownResourceId(), amount)); + ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager + .convertStageToResource(stageId, TestResourceId.getUnknownResourceId(), amount)); assertEquals(ResourceError.UNKNOWN_RESOURCE_ID, contractException.getErrorType()); }); @@ -787,7 +810,8 @@ public void testStageToResourceConversionEvent() { ResourceId resourceId = TestResourceId.RESOURCE_1; long amount = 15L; // if the stage id is null - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.convertStageToResource(null, resourceId, amount)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.convertStageToResource(null, resourceId, amount)); assertEquals(MaterialsError.NULL_STAGE_ID, contractException.getErrorType()); }); @@ -796,7 +820,8 @@ public void testStageToResourceConversionEvent() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); ResourceId resourceId = TestResourceId.RESOURCE_1; long amount = 15L; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.convertStageToResource(new StageId(10000000), resourceId, amount)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.convertStageToResource(new StageId(10000000), resourceId, amount)); assertEquals(MaterialsError.UNKNOWN_STAGE_ID, contractException.getErrorType()); }); @@ -807,7 +832,8 @@ public void testStageToResourceConversionEvent() { ResourceId resourceId = TestResourceId.RESOURCE_1; long amount = 15L; materialsDataManager.setStageOfferState(stageId, true); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.convertStageToResource(stageId, resourceId, amount)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.convertStageToResource(stageId, resourceId, amount)); assertEquals(MaterialsError.OFFERED_STAGE_UNALTERABLE, contractException.getErrorType()); materialsDataManager.setStageOfferState(stageId, false); }); @@ -817,7 +843,8 @@ public void testStageToResourceConversionEvent() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); ResourceId resourceId = TestResourceId.RESOURCE_1; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.convertStageToResource(stageId, resourceId, -1L)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.convertStageToResource(stageId, resourceId, -1L)); assertEquals(ResourceError.NEGATIVE_RESOURCE_AMOUNT, contractException.getErrorType()); }); @@ -833,7 +860,8 @@ public void testStageToResourceConversionEvent() { // on the producer StageId stageId2 = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); materialsDataManager.convertStageToResource(stageId2, resourceId, 10); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.convertStageToResource(stageId, resourceId, Long.MAX_VALUE)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.convertStageToResource(stageId, resourceId, Long.MAX_VALUE)); assertEquals(ResourceError.RESOURCE_ARITHMETIC_EXCEPTION, contractException.getErrorType()); }); @@ -854,7 +882,8 @@ public void testGetBatchAmount() { for (int i = 0; i < 100; i++) { TestMaterialId testMaterialId = TestMaterialId.getRandomMaterialId(randomGenerator); double value = randomGenerator.nextDouble() * 100; - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, testMaterialId, value, randomGenerator); + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, testMaterialId, value, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); // show that the batch matches the inputs @@ -864,11 +893,13 @@ public void testGetBatchAmount() { // precondition tests : none // if the batch id is null - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getBatchAmount(null)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getBatchAmount(null)); assertEquals(MaterialsError.NULL_BATCH_ID, contractException.getErrorType()); // if the batch id is unknown - contractException = assertThrows(ContractException.class, () -> materialsDataManager.getBatchAmount(new BatchId(10000000))); + contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getBatchAmount(new BatchId(10000000))); assertEquals(MaterialsError.UNKNOWN_BATCH_ID, contractException.getErrorType()); })); @@ -890,7 +921,8 @@ public void testGetBatchMaterial() { for (int i = 0; i < 100; i++) { TestMaterialId testMaterialId = TestMaterialId.getRandomMaterialId(randomGenerator); double value = randomGenerator.nextDouble() * 100; - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_2, testMaterialId, value, randomGenerator); + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_2, testMaterialId, value, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); // show that the batch matches the inputs @@ -902,7 +934,8 @@ public void testGetBatchMaterial() { /* precondition test: if the batch id is null */ MaterialsActionSupport.testConsumer(8694113802920961598L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getBatchMaterial(null)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getBatchMaterial(null)); assertEquals(MaterialsError.NULL_BATCH_ID, contractException.getErrorType()); }); @@ -910,7 +943,8 @@ public void testGetBatchMaterial() { MaterialsActionSupport.testConsumer(6524569565798029395L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); ContractException // if the batch id is unknown - contractException = assertThrows(ContractException.class, () -> materialsDataManager.getBatchMaterial(new BatchId(10000000))); + contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getBatchMaterial(new BatchId(10000000))); assertEquals(MaterialsError.UNKNOWN_BATCH_ID, contractException.getErrorType()); }); } @@ -933,7 +967,8 @@ public void testGetBatchProducer() { TestMaterialId testMaterialId = TestMaterialId.getRandomMaterialId(randomGenerator); double value = randomGenerator.nextDouble() * 100; - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(testMaterialsProducerId, testMaterialId, value, randomGenerator); + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo + .getBatchConstructionInfo(testMaterialsProducerId, testMaterialId, value, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); // show that the batch matches the inputs @@ -951,7 +986,8 @@ public void testGetBatchProducer() { MaterialsActionSupport.testConsumer(1422948417739515067L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getBatchProducer(null)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getBatchProducer(null)); assertEquals(MaterialsError.NULL_BATCH_ID, contractException.getErrorType()); }); @@ -960,7 +996,8 @@ public void testGetBatchProducer() { MaterialsActionSupport.testConsumer(6083037726892077495L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getBatchProducer(new BatchId(10000000))); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getBatchProducer(new BatchId(10000000))); assertEquals(MaterialsError.UNKNOWN_BATCH_ID, contractException.getErrorType()); }); @@ -975,10 +1012,12 @@ public void testGetBatchPropertyDefinition() { for (TestMaterialId testMaterialId : TestMaterialId.values()) { - Set testBatchPropertyIds = TestBatchPropertyId.getTestBatchPropertyIds(testMaterialId); + Set testBatchPropertyIds = TestBatchPropertyId + .getTestBatchPropertyIds(testMaterialId); for (TestBatchPropertyId testBatchPropertyId : testBatchPropertyIds) { PropertyDefinition expectedPropertyDefinition = testBatchPropertyId.getPropertyDefinition(); - PropertyDefinition actualPropertyDefinition = materialsDataManager.getBatchPropertyDefinition(testMaterialId, testBatchPropertyId); + PropertyDefinition actualPropertyDefinition = materialsDataManager + .getBatchPropertyDefinition(testMaterialId, testBatchPropertyId); assertEquals(expectedPropertyDefinition, actualPropertyDefinition); } } @@ -989,7 +1028,8 @@ public void testGetBatchPropertyDefinition() { MaterialsActionSupport.testConsumer(5856664286545303775L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); TestBatchPropertyId testBatchPropertyId = TestBatchPropertyId.BATCH_PROPERTY_2_3_DOUBLE_MUTABLE_TRACK; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getBatchPropertyDefinition(null, testBatchPropertyId)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getBatchPropertyDefinition(null, testBatchPropertyId)); assertEquals(MaterialsError.NULL_MATERIAL_ID, contractException.getErrorType()); }); @@ -998,14 +1038,16 @@ public void testGetBatchPropertyDefinition() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); TestBatchPropertyId testBatchPropertyId = TestBatchPropertyId.BATCH_PROPERTY_2_3_DOUBLE_MUTABLE_TRACK; ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.getBatchPropertyDefinition(TestMaterialId.getUnknownMaterialId(), testBatchPropertyId)); + () -> materialsDataManager.getBatchPropertyDefinition(TestMaterialId.getUnknownMaterialId(), + testBatchPropertyId)); assertEquals(MaterialsError.UNKNOWN_MATERIAL_ID, contractException.getErrorType()); }); /* precondition tests if the batch property id is null */ MaterialsActionSupport.testConsumer(2977320444281387466L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getBatchPropertyDefinition(TestMaterialId.MATERIAL_1, null)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getBatchPropertyDefinition(TestMaterialId.MATERIAL_1, null)); assertEquals(PropertyError.NULL_PROPERTY_ID, contractException.getErrorType()); }); @@ -1013,7 +1055,8 @@ public void testGetBatchPropertyDefinition() { MaterialsActionSupport.testConsumer(712791219730643932L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.getBatchPropertyDefinition(TestMaterialId.MATERIAL_1, TestBatchPropertyId.getUnknownBatchPropertyId())); + () -> materialsDataManager.getBatchPropertyDefinition(TestMaterialId.MATERIAL_1, + TestBatchPropertyId.getUnknownBatchPropertyId())); assertEquals(PropertyError.UNKNOWN_PROPERTY_ID, contractException.getErrorType()); }); @@ -1027,7 +1070,8 @@ public void testGetBatchPropertyIds() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); for (TestMaterialId testMaterialId : TestMaterialId.values()) { - Set expectedBatchPropertyIds = TestBatchPropertyId.getTestBatchPropertyIds(testMaterialId); + Set expectedBatchPropertyIds = TestBatchPropertyId + .getTestBatchPropertyIds(testMaterialId); Set actualBatchPropertyIds = materialsDataManager.getBatchPropertyIds(testMaterialId); assertEquals(expectedBatchPropertyIds, actualBatchPropertyIds); } @@ -1035,11 +1079,13 @@ public void testGetBatchPropertyIds() { // precondition tests // if the material id is null - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getBatchPropertyIds(null)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getBatchPropertyIds(null)); assertEquals(MaterialsError.NULL_MATERIAL_ID, contractException.getErrorType()); // if the material id is unknown - contractException = assertThrows(ContractException.class, () -> materialsDataManager.getBatchPropertyIds(TestMaterialId.getUnknownMaterialId())); + contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getBatchPropertyIds(TestMaterialId.getUnknownMaterialId())); assertEquals(MaterialsError.UNKNOWN_MATERIAL_ID, contractException.getErrorType()); }); @@ -1047,14 +1093,16 @@ public void testGetBatchPropertyIds() { /* precondition test: if the material id is null */ MaterialsActionSupport.testConsumer(6822125249787156609L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getBatchPropertyIds(null)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getBatchPropertyIds(null)); assertEquals(MaterialsError.NULL_MATERIAL_ID, contractException.getErrorType()); }); /* precondition test: if the material id is unknown */ MaterialsActionSupport.testConsumer(7025275053813907413L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getBatchPropertyIds(TestMaterialId.getUnknownMaterialId())); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getBatchPropertyIds(TestMaterialId.getUnknownMaterialId())); assertEquals(MaterialsError.UNKNOWN_MATERIAL_ID, contractException.getErrorType()); }); @@ -1084,7 +1132,8 @@ public void testGetBatchPropertyTime() { for (int i = 0; i < 50; i++) { MaterialId materialId = TestMaterialId.getRandomMaterialId(randomGenerator); double amount = randomGenerator.nextDouble(); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_3, materialId, amount, randomGenerator); + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_3, materialId, amount, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); Set batchPropertyIds = materialsDataManager.getBatchPropertyIds(materialId); for (TestBatchPropertyId batchPropertyId : batchPropertyIds) { @@ -1108,7 +1157,8 @@ public void testGetBatchPropertyTime() { // alter the batch properties - List inventoryBatches = materialsDataManager.getInventoryBatches(TestMaterialsProducerId.MATERIALS_PRODUCER_3); + List inventoryBatches = materialsDataManager + .getInventoryBatches(TestMaterialsProducerId.MATERIALS_PRODUCER_3); for (BatchId batchId : inventoryBatches) { MaterialId materialId = materialsDataManager.getBatchMaterial(batchId); Set batchPropertyIds = materialsDataManager.getBatchPropertyIds(materialId); @@ -1117,7 +1167,8 @@ public void testGetBatchPropertyTime() { if (randomGenerator.nextDouble() < 0.5) { Object value = batchPropertyId.getRandomPropertyValue(randomGenerator); materialsDataManager.setBatchPropertyValue(batchId, batchPropertyId, value); - MutableDouble mutableDouble = expectedAssignmentTimes.get(new MultiKey(batchId, batchPropertyId)); + MutableDouble mutableDouble = expectedAssignmentTimes + .get(new MultiKey(batchId, batchPropertyId)); mutableDouble.setValue(c.getTime()); } } @@ -1143,9 +1194,11 @@ public void testGetBatchPropertyTime() { Set batchPropertyIds = materialsDataManager.getBatchPropertyIds(materialId); for (TestBatchPropertyId batchPropertyId : batchPropertyIds) { if (randomGenerator.nextDouble() < 0.33) { - MutableDouble mutableDouble = expectedAssignmentTimes.get(new MultiKey(batchId, batchPropertyId)); + MutableDouble mutableDouble = expectedAssignmentTimes + .get(new MultiKey(batchId, batchPropertyId)); double expectedAssignmentTime = mutableDouble.getValue(); - double actualAssignmentTime = materialsDataManager.getBatchPropertyTime(batchId, batchPropertyId); + double actualAssignmentTime = materialsDataManager.getBatchPropertyTime(batchId, + batchPropertyId); assertEquals(expectedAssignmentTime, actualAssignmentTime); } } @@ -1162,7 +1215,8 @@ public void testGetBatchPropertyTime() { MaterialsActionSupport.testConsumer(411385203720638722L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); BatchPropertyId batchPropertyId = TestBatchPropertyId.BATCH_PROPERTY_1_1_BOOLEAN_IMMUTABLE_NO_TRACK; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getBatchPropertyTime(null, batchPropertyId)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getBatchPropertyTime(null, batchPropertyId)); assertEquals(MaterialsError.NULL_BATCH_ID, contractException.getErrorType()); }); @@ -1170,7 +1224,8 @@ public void testGetBatchPropertyTime() { MaterialsActionSupport.testConsumer(6352485251167807955L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); BatchPropertyId batchPropertyId = TestBatchPropertyId.BATCH_PROPERTY_1_1_BOOLEAN_IMMUTABLE_NO_TRACK; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getBatchPropertyTime(new BatchId(100000), batchPropertyId)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getBatchPropertyTime(new BatchId(100000), batchPropertyId)); assertEquals(MaterialsError.UNKNOWN_BATCH_ID, contractException.getErrorType()); }); @@ -1179,10 +1234,12 @@ public void testGetBatchPropertyTime() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_3, TestMaterialId.MATERIAL_2, 15L, + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_3, TestMaterialId.MATERIAL_2, 15L, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getBatchPropertyTime(batchId, null)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getBatchPropertyTime(batchId, null)); assertEquals(PropertyError.NULL_PROPERTY_ID, contractException.getErrorType()); }); @@ -1191,10 +1248,12 @@ public void testGetBatchPropertyTime() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_2, 65L, + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_2, 65L, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getBatchPropertyTime(batchId, TestBatchPropertyId.getUnknownBatchPropertyId())); + ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager + .getBatchPropertyTime(batchId, TestBatchPropertyId.getUnknownBatchPropertyId())); assertEquals(PropertyError.UNKNOWN_PROPERTY_ID, contractException.getErrorType()); }); } @@ -1227,7 +1286,8 @@ public void testGetBatchPropertyValue() { MaterialId materialId = TestMaterialId.getRandomMaterialId(randomGenerator); double amount = randomGenerator.nextDouble(); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_2, materialId, amount, randomGenerator); + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_2, materialId, amount, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); Set batchPropertyIds = materialsDataManager.getBatchPropertyIds(materialId); @@ -1241,10 +1301,12 @@ public void testGetBatchPropertyValue() { for (int i = 0; i < 200; i++) { - List inventoryBatches = materialsDataManager.getInventoryBatches(TestMaterialsProducerId.MATERIALS_PRODUCER_2); + List inventoryBatches = materialsDataManager + .getInventoryBatches(TestMaterialsProducerId.MATERIALS_PRODUCER_2); BatchId batchId = inventoryBatches.get(randomGenerator.nextInt(inventoryBatches.size())); TestMaterialId materialId = materialsDataManager.getBatchMaterial(batchId); - TestBatchPropertyId batchPropertyId = TestBatchPropertyId.getRandomMutableBatchPropertyId(materialId, randomGenerator); + TestBatchPropertyId batchPropertyId = TestBatchPropertyId.getRandomMutableBatchPropertyId(materialId, + randomGenerator); Object value = batchPropertyId.getRandomPropertyValue(randomGenerator); materialsDataManager.setBatchPropertyValue(batchId, batchPropertyId, value); expectedValues.put(new MultiKey(batchId, batchPropertyId), value); @@ -1278,7 +1340,8 @@ public void testGetBatchPropertyValue() { MaterialsActionSupport.testConsumer(7782292483170344303L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); BatchPropertyId batchPropertyId = TestBatchPropertyId.BATCH_PROPERTY_1_1_BOOLEAN_IMMUTABLE_NO_TRACK; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getBatchPropertyValue(null, batchPropertyId)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getBatchPropertyValue(null, batchPropertyId)); assertEquals(MaterialsError.NULL_BATCH_ID, contractException.getErrorType()); }); @@ -1286,7 +1349,8 @@ public void testGetBatchPropertyValue() { MaterialsActionSupport.testConsumer(2235610256211958684L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); BatchPropertyId batchPropertyId = TestBatchPropertyId.BATCH_PROPERTY_1_1_BOOLEAN_IMMUTABLE_NO_TRACK; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getBatchPropertyValue(new BatchId(100000), batchPropertyId)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getBatchPropertyValue(new BatchId(100000), batchPropertyId)); assertEquals(MaterialsError.UNKNOWN_BATCH_ID, contractException.getErrorType()); }); @@ -1295,10 +1359,12 @@ public void testGetBatchPropertyValue() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_2, 45L, + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_2, 45L, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getBatchPropertyValue(batchId, null)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getBatchPropertyValue(batchId, null)); assertEquals(PropertyError.NULL_PROPERTY_ID, contractException.getErrorType()); }); @@ -1307,10 +1373,12 @@ public void testGetBatchPropertyValue() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_2, 45L, + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_2, 45L, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getBatchPropertyValue(batchId, TestBatchPropertyId.getUnknownBatchPropertyId())); + ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager + .getBatchPropertyValue(batchId, TestBatchPropertyId.getUnknownBatchPropertyId())); assertEquals(PropertyError.UNKNOWN_PROPERTY_ID, contractException.getErrorType()); }); @@ -1328,7 +1396,8 @@ public void testGetBatchStageId() { // create a stage and a batch StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_3); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_3, TestMaterialId.MATERIAL_2, 4.5, + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_3, TestMaterialId.MATERIAL_2, 4.5, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); @@ -1355,14 +1424,16 @@ public void testGetBatchStageId() { /* precondition test: if the batch id is null */ MaterialsActionSupport.testConsumer(8182230906627557939L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getBatchStageId(null)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getBatchStageId(null)); assertEquals(MaterialsError.NULL_BATCH_ID, contractException.getErrorType()); }); /* precondition test: if the batch id is unknown */ MaterialsActionSupport.testConsumer(3682958492574276233L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getBatchStageId(new BatchId(100000))); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getBatchStageId(new BatchId(100000))); assertEquals(MaterialsError.UNKNOWN_BATCH_ID, contractException.getErrorType()); }); } @@ -1386,7 +1457,8 @@ public void testGetBatchTime() { pluginBuilder.addTestActorPlan("actor", new TestActorPlan(planTime, (c) -> { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); - TestMaterialsProducerId materialsProducerId = TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator); + TestMaterialsProducerId materialsProducerId = TestMaterialsProducerId + .getRandomMaterialsProducerId(randomGenerator); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); // build a few batches @@ -1395,7 +1467,8 @@ public void testGetBatchTime() { TestMaterialId materialId = TestMaterialId.getRandomMaterialId(randomGenerator); double amount = randomGenerator.nextDouble(); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(materialsProducerId, materialId, amount, randomGenerator); + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo + .getBatchConstructionInfo(materialsProducerId, materialId, amount, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); expectedBatchTimes.put(batchId, c.getTime()); } @@ -1420,14 +1493,16 @@ public void testGetBatchTime() { /* precondition test: if the batch id is null */ MaterialsActionSupport.testConsumer(2942652850143901549L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getBatchTime(null)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getBatchTime(null)); assertEquals(MaterialsError.NULL_BATCH_ID, contractException.getErrorType()); }); /* precondition test: if the batch id is unknown */ MaterialsActionSupport.testConsumer(8578067293001466760L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getBatchTime(new BatchId(1000000))); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getBatchTime(new BatchId(1000000))); assertEquals(MaterialsError.UNKNOWN_BATCH_ID, contractException.getErrorType()); }); } @@ -1454,7 +1529,8 @@ public void testGetInventoryBatches() { // create some batches for (int i = 0; i < 100; i++) { - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(testMaterialsProducerId, TestMaterialId.getRandomMaterialId(randomGenerator), + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + testMaterialsProducerId, TestMaterialId.getRandomMaterialId(randomGenerator), randomGenerator.nextInt(100), randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); expectedInventoryBatches.add(batchId); @@ -1511,14 +1587,16 @@ public void testGetInventoryBatches() { /* precondition tests if the materials producerId id is null */ MaterialsActionSupport.testConsumer(6759896268818524420L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getInventoryBatches(null)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getInventoryBatches(null)); assertEquals(MaterialsError.NULL_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); /* precondition tests if the materials producerId id is unknown */ MaterialsActionSupport.testConsumer(944257921550728616L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getInventoryBatches(TestMaterialsProducerId.getUnknownMaterialsProducerId())); + ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager + .getInventoryBatches(TestMaterialsProducerId.getUnknownMaterialsProducerId())); assertEquals(MaterialsError.UNKNOWN_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); @@ -1549,21 +1627,25 @@ public void testGetInventoryBatchesByMaterialId() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); - MaterialsProducerId materialsProducerId = TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator); + MaterialsProducerId materialsProducerId = TestMaterialsProducerId + .getRandomMaterialsProducerId(randomGenerator); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - Map> materialToBatchesMap = expectedInventoryBatchesMap.get(materialsProducerId); + Map> materialToBatchesMap = expectedInventoryBatchesMap + .get(materialsProducerId); // create some (100) batches for (int i = 0; i < 100; i++) { MaterialId materialId = TestMaterialId.getRandomMaterialId(randomGenerator); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(materialsProducerId, materialId, randomGenerator.nextInt(100), randomGenerator); + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + materialsProducerId, materialId, randomGenerator.nextInt(100), randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); materialToBatchesMap.get(materialId).add(batchId); } // show that the inventory batches are correct for (TestMaterialId testMaterialId : TestMaterialId.values()) { - List batchList = materialsDataManager.getInventoryBatchesByMaterialId(materialsProducerId, testMaterialId); + List batchList = materialsDataManager.getInventoryBatchesByMaterialId(materialsProducerId, + testMaterialId); Set actualInventoryBatches = new LinkedHashSet<>(batchList); assertEquals(batchList.size(), actualInventoryBatches.size()); Set expectedInventoryBatches = materialToBatchesMap.get(testMaterialId); @@ -1609,9 +1691,11 @@ public void testGetInventoryBatchesByMaterialId() { // show that the inventory batches are correct for (TestMaterialsProducerId testMaterialsProducerId : TestMaterialsProducerId.values()) { - Map> materialToBatchesMap = expectedInventoryBatchesMap.get(testMaterialsProducerId); + Map> materialToBatchesMap = expectedInventoryBatchesMap + .get(testMaterialsProducerId); for (TestMaterialId testMaterialId : TestMaterialId.values()) { - List invBatches = materialsDataManager.getInventoryBatchesByMaterialId(testMaterialsProducerId, testMaterialId); + List invBatches = materialsDataManager + .getInventoryBatchesByMaterialId(testMaterialsProducerId, testMaterialId); Set actualInventoryBatches = new LinkedHashSet<>(invBatches); assertEquals(invBatches.size(), actualInventoryBatches.size()); Set expectedInventoryBatches = materialToBatchesMap.get(testMaterialId); @@ -1627,7 +1711,8 @@ public void testGetInventoryBatchesByMaterialId() { /* precondition test: if the materials producerId id is null */ MaterialsActionSupport.testConsumer(8066333940937253765L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getInventoryBatchesByMaterialId(null, TestMaterialId.MATERIAL_1)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getInventoryBatchesByMaterialId(null, TestMaterialId.MATERIAL_1)); assertEquals(MaterialsError.NULL_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); @@ -1635,14 +1720,16 @@ public void testGetInventoryBatchesByMaterialId() { MaterialsActionSupport.testConsumer(3143917391309849287L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.getInventoryBatchesByMaterialId(TestMaterialsProducerId.getUnknownMaterialsProducerId(), TestMaterialId.MATERIAL_2)); + () -> materialsDataManager.getInventoryBatchesByMaterialId( + TestMaterialsProducerId.getUnknownMaterialsProducerId(), TestMaterialId.MATERIAL_2)); assertEquals(MaterialsError.UNKNOWN_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); /* precondition test: if the material id is null */ MaterialsActionSupport.testConsumer(874196115936784556L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getInventoryBatchesByMaterialId(TestMaterialsProducerId.MATERIALS_PRODUCER_1, null)); + ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager + .getInventoryBatchesByMaterialId(TestMaterialsProducerId.MATERIALS_PRODUCER_1, null)); assertEquals(MaterialsError.NULL_MATERIAL_ID, contractException.getErrorType()); }); @@ -1650,7 +1737,8 @@ public void testGetInventoryBatchesByMaterialId() { MaterialsActionSupport.testConsumer(9112311292467047420L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.getInventoryBatchesByMaterialId(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.getUnknownMaterialId())); + () -> materialsDataManager.getInventoryBatchesByMaterialId( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.getUnknownMaterialId())); assertEquals(MaterialsError.UNKNOWN_MATERIAL_ID, contractException.getErrorType()); }); @@ -1697,9 +1785,11 @@ public void testGetMaterialsProducerPropertyDefinition() { MaterialsActionSupport.testConsumer(7151961147034751776L, (c) -> { MaterialsDataManager materialsDaView = c.getDataManager(MaterialsDataManager.class); - for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId.values()) { + for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId + .values()) { PropertyDefinition expectedPropertyDefinition = testMaterialsProducerPropertyId.getPropertyDefinition(); - PropertyDefinition actualPropertyDefinition = materialsDaView.getMaterialsProducerPropertyDefinition(testMaterialsProducerPropertyId); + PropertyDefinition actualPropertyDefinition = materialsDaView + .getMaterialsProducerPropertyDefinition(testMaterialsProducerPropertyId); assertEquals(expectedPropertyDefinition, actualPropertyDefinition); } @@ -1708,7 +1798,8 @@ public void testGetMaterialsProducerPropertyDefinition() { /* precondition test: if the materials producer property id is null */ MaterialsActionSupport.testConsumer(4030472148503907839L, (c) -> { MaterialsDataManager materialsDaView = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDaView.getMaterialsProducerPropertyDefinition(null)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDaView.getMaterialsProducerPropertyDefinition(null)); assertEquals(PropertyError.NULL_PROPERTY_ID, contractException.getErrorType()); }); @@ -1718,7 +1809,8 @@ public void testGetMaterialsProducerPropertyDefinition() { MaterialsActionSupport.testConsumer(863172317284141879L, (c) -> { MaterialsDataManager materialsDaView = c.getDataManager(MaterialsDataManager.class); ContractException contractException = assertThrows(ContractException.class, - () -> materialsDaView.getMaterialsProducerPropertyDefinition(TestMaterialsProducerPropertyId.getUnknownMaterialsProducerPropertyId())); + () -> materialsDaView.getMaterialsProducerPropertyDefinition( + TestMaterialsProducerPropertyId.getUnknownMaterialsProducerPropertyId())); assertEquals(PropertyError.UNKNOWN_PROPERTY_ID, contractException.getErrorType()); }); @@ -1729,12 +1821,14 @@ public void testGetMaterialsProducerPropertyDefinition() { public void testGetMaterialsProducerPropertyIds() { MaterialsActionSupport.testConsumer(8718225529106870071L, (c) -> { MaterialsDataManager materialsDaView = c.getDataManager(MaterialsDataManager.class); - assertEquals(EnumSet.allOf(TestMaterialsProducerPropertyId.class), materialsDaView.getMaterialsProducerPropertyIds()); + assertEquals(EnumSet.allOf(TestMaterialsProducerPropertyId.class), + materialsDaView.getMaterialsProducerPropertyIds()); }); } @Test - @UnitTestMethod(name = "getMaterialsProducerPropertyTime", args = { MaterialsProducerId.class, MaterialsProducerPropertyId.class }) + @UnitTestMethod(name = "getMaterialsProducerPropertyTime", args = { MaterialsProducerId.class, + MaterialsProducerPropertyId.class }) public void testGetMaterialsProducerPropertyTime() { TestPluginData.Builder pluginBuilder = TestPluginData.builder(); @@ -1743,8 +1837,10 @@ public void testGetMaterialsProducerPropertyTime() { // producer property values Map expectedTimesMap = new LinkedHashMap<>(); for (TestMaterialsProducerId testMaterialsProducerId : TestMaterialsProducerId.values()) { - for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId.values()) { - expectedTimesMap.put(new MultiKey(testMaterialsProducerId, testMaterialsProducerPropertyId), new MutableDouble()); + for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId + .values()) { + expectedTimesMap.put(new MultiKey(testMaterialsProducerId, testMaterialsProducerPropertyId), + new MutableDouble()); } } @@ -1759,10 +1855,13 @@ public void testGetMaterialsProducerPropertyTime() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); for (int j = 0; j < propertyChangeCount; j++) { - TestMaterialsProducerId materialsProducerId = TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator); - TestMaterialsProducerPropertyId materialsProducerPropertyId = TestMaterialsProducerPropertyId.getRandomMutableMaterialsProducerPropertyId(randomGenerator); + TestMaterialsProducerId materialsProducerId = TestMaterialsProducerId + .getRandomMaterialsProducerId(randomGenerator); + TestMaterialsProducerPropertyId materialsProducerPropertyId = TestMaterialsProducerPropertyId + .getRandomMutableMaterialsProducerPropertyId(randomGenerator); Object propertyValue = materialsProducerPropertyId.getRandomPropertyValue(randomGenerator); - materialsDataManager.setMaterialsProducerPropertyValue(materialsProducerId, materialsProducerPropertyId, propertyValue); + materialsDataManager.setMaterialsProducerPropertyValue(materialsProducerId, + materialsProducerPropertyId, propertyValue); MultiKey multiKey = new MultiKey(materialsProducerId, materialsProducerPropertyId); expectedTimesMap.get(multiKey).setValue(c.getTime()); } @@ -1772,10 +1871,12 @@ public void testGetMaterialsProducerPropertyTime() { pluginBuilder.addTestActorPlan("actor", new TestActorPlan(10, (c) -> { MaterialsDataManager materialsDaView = c.getDataManager(MaterialsDataManager.class); for (TestMaterialsProducerId testMaterialsProducerId : TestMaterialsProducerId.values()) { - for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId.values()) { + for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId + .values()) { MultiKey multiKey = new MultiKey(testMaterialsProducerId, testMaterialsProducerPropertyId); double expectedTime = expectedTimesMap.get(multiKey).getValue(); - double actualTime = materialsDaView.getMaterialsProducerPropertyTime(testMaterialsProducerId, testMaterialsProducerPropertyId); + double actualTime = materialsDaView.getMaterialsProducerPropertyTime(testMaterialsProducerId, + testMaterialsProducerPropertyId); assertEquals(expectedTime, actualTime); } } @@ -1789,22 +1890,26 @@ public void testGetMaterialsProducerPropertyTime() { MaterialsActionSupport.testConsumer(8047663013308359028L, (c) -> { MaterialsDataManager materialsDaView = c.getDataManager(MaterialsDataManager.class); ContractException contractException = assertThrows(ContractException.class, - () -> materialsDaView.getMaterialsProducerPropertyTime(null, TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_4_BOOLEAN_MUTABLE_TRACK)); + () -> materialsDaView.getMaterialsProducerPropertyTime(null, + TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_4_BOOLEAN_MUTABLE_TRACK)); assertEquals(MaterialsError.NULL_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); /* precondition test: if the materials producerId id is unknown */ MaterialsActionSupport.testConsumer(7076209560671384217L, (c) -> { MaterialsDataManager materialsDaView = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDaView.getMaterialsProducerPropertyTime(TestMaterialsProducerId.getUnknownMaterialsProducerId(), - TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_4_BOOLEAN_MUTABLE_TRACK)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDaView.getMaterialsProducerPropertyTime( + TestMaterialsProducerId.getUnknownMaterialsProducerId(), + TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_4_BOOLEAN_MUTABLE_TRACK)); assertEquals(MaterialsError.UNKNOWN_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); /* precondition test: if the materials producerId property id is null */ MaterialsActionSupport.testConsumer(8444324674368897195L, (c) -> { MaterialsDataManager materialsDaView = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDaView.getMaterialsProducerPropertyTime(TestMaterialsProducerId.MATERIALS_PRODUCER_1, null)); + ContractException contractException = assertThrows(ContractException.class, () -> materialsDaView + .getMaterialsProducerPropertyTime(TestMaterialsProducerId.MATERIALS_PRODUCER_1, null)); assertEquals(PropertyError.NULL_PROPERTY_ID, contractException.getErrorType()); }); @@ -1814,14 +1919,16 @@ public void testGetMaterialsProducerPropertyTime() { MaterialsActionSupport.testConsumer(3195486517854831744L, (c) -> { MaterialsDataManager materialsDaView = c.getDataManager(MaterialsDataManager.class); ContractException contractException = assertThrows(ContractException.class, - () -> materialsDaView.getMaterialsProducerPropertyTime(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialsProducerPropertyId.getUnknownMaterialsProducerPropertyId())); + () -> materialsDaView.getMaterialsProducerPropertyTime(TestMaterialsProducerId.MATERIALS_PRODUCER_1, + TestMaterialsProducerPropertyId.getUnknownMaterialsProducerPropertyId())); assertEquals(PropertyError.UNKNOWN_PROPERTY_ID, contractException.getErrorType()); }); } @Test - @UnitTestMethod(name = "getMaterialsProducerPropertyValue", args = { MaterialsProducerId.class, MaterialsProducerPropertyId.class }) + @UnitTestMethod(name = "getMaterialsProducerPropertyValue", args = { MaterialsProducerId.class, + MaterialsProducerPropertyId.class }) public void testGetMaterialsProducerPropertyValue() { TestPluginData.Builder pluginBuilder = TestPluginData.builder(); @@ -1835,9 +1942,11 @@ public void testGetMaterialsProducerPropertyValue() { MaterialsDataManager materialsDaView = c.getDataManager(MaterialsDataManager.class); for (TestMaterialsProducerId testMaterialsProducerId : TestMaterialsProducerId.values()) { - for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId.values()) { + for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId + .values()) { MultiKey multiKey = new MultiKey(testMaterialsProducerId, testMaterialsProducerPropertyId); - Object value = materialsDaView.getMaterialsProducerPropertyValue(testMaterialsProducerId, testMaterialsProducerPropertyId); + Object value = materialsDaView.getMaterialsProducerPropertyValue(testMaterialsProducerId, + testMaterialsProducerPropertyId); expectedValuesMap.put(multiKey, value); } } @@ -1854,10 +1963,13 @@ public void testGetMaterialsProducerPropertyValue() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); for (int j = 0; j < propertyChangeCount; j++) { - TestMaterialsProducerId materialsProducerId = TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator); - TestMaterialsProducerPropertyId materialsProducerPropertyId = TestMaterialsProducerPropertyId.getRandomMutableMaterialsProducerPropertyId(randomGenerator); + TestMaterialsProducerId materialsProducerId = TestMaterialsProducerId + .getRandomMaterialsProducerId(randomGenerator); + TestMaterialsProducerPropertyId materialsProducerPropertyId = TestMaterialsProducerPropertyId + .getRandomMutableMaterialsProducerPropertyId(randomGenerator); Object propertyValue = materialsProducerPropertyId.getRandomPropertyValue(randomGenerator); - materialsDataManager.setMaterialsProducerPropertyValue(materialsProducerId, materialsProducerPropertyId, propertyValue); + materialsDataManager.setMaterialsProducerPropertyValue(materialsProducerId, + materialsProducerPropertyId, propertyValue); MultiKey multiKey = new MultiKey(materialsProducerId, materialsProducerPropertyId); expectedValuesMap.put(multiKey, propertyValue); } @@ -1867,10 +1979,12 @@ public void testGetMaterialsProducerPropertyValue() { pluginBuilder.addTestActorPlan("actor", new TestActorPlan(10, (c) -> { MaterialsDataManager materialsDaView = c.getDataManager(MaterialsDataManager.class); for (TestMaterialsProducerId testMaterialsProducerId : TestMaterialsProducerId.values()) { - for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId.values()) { + for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId + .values()) { MultiKey multiKey = new MultiKey(testMaterialsProducerId, testMaterialsProducerPropertyId); Object expectedValue = expectedValuesMap.get(multiKey); - Object actualValue = materialsDaView.getMaterialsProducerPropertyValue(testMaterialsProducerId, testMaterialsProducerPropertyId); + Object actualValue = materialsDaView.getMaterialsProducerPropertyValue(testMaterialsProducerId, + testMaterialsProducerPropertyId); assertEquals(expectedValue, actualValue); } } @@ -1884,22 +1998,26 @@ public void testGetMaterialsProducerPropertyValue() { MaterialsActionSupport.testConsumer(4247143641356704364L, (c) -> { MaterialsDataManager materialsDaView = c.getDataManager(MaterialsDataManager.class); ContractException contractException = assertThrows(ContractException.class, - () -> materialsDaView.getMaterialsProducerPropertyValue(null, TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_4_BOOLEAN_MUTABLE_TRACK)); + () -> materialsDaView.getMaterialsProducerPropertyValue(null, + TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_4_BOOLEAN_MUTABLE_TRACK)); assertEquals(MaterialsError.NULL_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); /* precondition test: if the materials producerId id is unknown */ MaterialsActionSupport.testConsumer(7731689857034028615L, (c) -> { MaterialsDataManager materialsDaView = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDaView.getMaterialsProducerPropertyValue(TestMaterialsProducerId.getUnknownMaterialsProducerId(), - TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_4_BOOLEAN_MUTABLE_TRACK)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDaView.getMaterialsProducerPropertyValue( + TestMaterialsProducerId.getUnknownMaterialsProducerId(), + TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_4_BOOLEAN_MUTABLE_TRACK)); assertEquals(MaterialsError.UNKNOWN_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); /* precondition test: if the materials producerId property id is null */ MaterialsActionSupport.testConsumer(1004792420489047936L, (c) -> { MaterialsDataManager materialsDaView = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDaView.getMaterialsProducerPropertyValue(TestMaterialsProducerId.MATERIALS_PRODUCER_1, null)); + ContractException contractException = assertThrows(ContractException.class, () -> materialsDaView + .getMaterialsProducerPropertyValue(TestMaterialsProducerId.MATERIALS_PRODUCER_1, null)); assertEquals(PropertyError.NULL_PROPERTY_ID, contractException.getErrorType()); }); @@ -1909,7 +2027,9 @@ public void testGetMaterialsProducerPropertyValue() { MaterialsActionSupport.testConsumer(133851619411326116L, (c) -> { MaterialsDataManager materialsDaView = c.getDataManager(MaterialsDataManager.class); ContractException contractException = assertThrows(ContractException.class, - () -> materialsDaView.getMaterialsProducerPropertyValue(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialsProducerPropertyId.getUnknownMaterialsProducerPropertyId())); + () -> materialsDaView.getMaterialsProducerPropertyValue( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, + TestMaterialsProducerPropertyId.getUnknownMaterialsProducerPropertyId())); assertEquals(PropertyError.UNKNOWN_PROPERTY_ID, contractException.getErrorType()); }); } @@ -1957,7 +2077,8 @@ public void testGetMaterialsProducerResourceLevel() { for (TestResourceId testResourceId : TestResourceId.values()) { MultiKey multiKey = new MultiKey(testMaterialsProducerId, testResourceId); long expectedLevel = expectedLevelsMap.get(multiKey).getValue(); - long actualLevel = materialsDataManager.getMaterialsProducerResourceLevel(testMaterialsProducerId, testResourceId); + long actualLevel = materialsDataManager.getMaterialsProducerResourceLevel(testMaterialsProducerId, + testResourceId); assertEquals(expectedLevel, actualLevel); } } @@ -1970,7 +2091,8 @@ public void testGetMaterialsProducerResourceLevel() { /* precondition test: if the materials producerId id is null */ MaterialsActionSupport.testConsumer(11082575022266925L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getMaterialsProducerResourceLevel(null, TestResourceId.RESOURCE_1)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getMaterialsProducerResourceLevel(null, TestResourceId.RESOURCE_1)); assertEquals(MaterialsError.NULL_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); @@ -1978,7 +2100,8 @@ public void testGetMaterialsProducerResourceLevel() { MaterialsActionSupport.testConsumer(6362058221207452078L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.getMaterialsProducerResourceLevel(TestMaterialsProducerId.getUnknownMaterialsProducerId(), TestResourceId.RESOURCE_1)); + () -> materialsDataManager.getMaterialsProducerResourceLevel( + TestMaterialsProducerId.getUnknownMaterialsProducerId(), TestResourceId.RESOURCE_1)); assertEquals(MaterialsError.UNKNOWN_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); @@ -1986,7 +2109,8 @@ public void testGetMaterialsProducerResourceLevel() { MaterialsActionSupport.testConsumer(7531288497048301736L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.getMaterialsProducerResourceLevel(TestMaterialsProducerId.MATERIALS_PRODUCER_1, null)); + () -> materialsDataManager + .getMaterialsProducerResourceLevel(TestMaterialsProducerId.MATERIALS_PRODUCER_1, null)); assertEquals(ResourceError.NULL_RESOURCE_ID, contractException.getErrorType()); }); @@ -1994,7 +2118,8 @@ public void testGetMaterialsProducerResourceLevel() { MaterialsActionSupport.testConsumer(2745862264533327311L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.getMaterialsProducerResourceLevel(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestResourceId.getUnknownResourceId())); + () -> materialsDataManager.getMaterialsProducerResourceLevel( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestResourceId.getUnknownResourceId())); assertEquals(ResourceError.UNKNOWN_RESOURCE_ID, contractException.getErrorType()); }); } @@ -2038,7 +2163,8 @@ public void testGetMaterialsProducerResourceTime() { for (TestResourceId testResourceId : TestResourceId.values()) { MultiKey multiKey = new MultiKey(testMaterialsProducerId, testResourceId); double expectedTime = expectedTimesMap.get(multiKey).getValue(); - double actualTime = materialsDataManager.getMaterialsProducerResourceTime(testMaterialsProducerId, testResourceId); + double actualTime = materialsDataManager.getMaterialsProducerResourceTime(testMaterialsProducerId, + testResourceId); assertEquals(expectedTime, actualTime); } } @@ -2051,7 +2177,8 @@ public void testGetMaterialsProducerResourceTime() { /* precondition test: if the materials producerId id is null */ MaterialsActionSupport.testConsumer(5802266741184871831L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getMaterialsProducerResourceTime(null, TestResourceId.RESOURCE_1)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getMaterialsProducerResourceTime(null, TestResourceId.RESOURCE_1)); assertEquals(MaterialsError.NULL_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); @@ -2059,7 +2186,8 @@ public void testGetMaterialsProducerResourceTime() { MaterialsActionSupport.testConsumer(4254859094661916110L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.getMaterialsProducerResourceTime(TestMaterialsProducerId.getUnknownMaterialsProducerId(), TestResourceId.RESOURCE_1)); + () -> materialsDataManager.getMaterialsProducerResourceTime( + TestMaterialsProducerId.getUnknownMaterialsProducerId(), TestResourceId.RESOURCE_1)); assertEquals(MaterialsError.UNKNOWN_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); @@ -2067,7 +2195,8 @@ public void testGetMaterialsProducerResourceTime() { MaterialsActionSupport.testConsumer(3911919336328300644L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.getMaterialsProducerResourceTime(TestMaterialsProducerId.MATERIALS_PRODUCER_1, null)); + () -> materialsDataManager + .getMaterialsProducerResourceTime(TestMaterialsProducerId.MATERIALS_PRODUCER_1, null)); assertEquals(ResourceError.NULL_RESOURCE_ID, contractException.getErrorType()); }); @@ -2075,7 +2204,8 @@ public void testGetMaterialsProducerResourceTime() { MaterialsActionSupport.testConsumer(2654216033515042203L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.getMaterialsProducerResourceTime(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestResourceId.getUnknownResourceId())); + () -> materialsDataManager.getMaterialsProducerResourceTime( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestResourceId.getUnknownResourceId())); assertEquals(ResourceError.UNKNOWN_RESOURCE_ID, contractException.getErrorType()); }); } @@ -2122,14 +2252,16 @@ public void testGetOfferedStages() { /* precondition tests if the materials producerId id is null */ MaterialsActionSupport.testConsumer(1728234953072549300L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getOfferedStages(null)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getOfferedStages(null)); assertEquals(MaterialsError.NULL_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); /* precondition tests if the materials producerId id is unknown */ MaterialsActionSupport.testConsumer(809512240800144004L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getOfferedStages(TestMaterialsProducerId.getUnknownMaterialsProducerId())); + ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager + .getOfferedStages(TestMaterialsProducerId.getUnknownMaterialsProducerId())); assertEquals(MaterialsError.UNKNOWN_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); @@ -2157,8 +2289,10 @@ public void testGetStageBatches() { int batchCount = randomGenerator.nextInt(3) + 1; Set batches = new LinkedHashSet<>(); for (int j = 0; j < batchCount; j++) { - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(testMaterialsProducerId, TestMaterialId.getRandomMaterialId(randomGenerator), - randomGenerator.nextInt(100), randomGenerator); + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo + .getBatchConstructionInfo(testMaterialsProducerId, + TestMaterialId.getRandomMaterialId(randomGenerator), + randomGenerator.nextInt(100), randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); batches.add(batchId); materialsDataManager.moveBatchToStage(batchId, stageId); @@ -2189,14 +2323,16 @@ public void testGetStageBatches() { /* precondition tests if the stage id is null */ MaterialsActionSupport.testConsumer(7434749084817685354L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getStageBatches(null)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getStageBatches(null)); assertEquals(MaterialsError.NULL_STAGE_ID, contractException.getErrorType()); }); /* precondition tests if the stage id is unknown */ MaterialsActionSupport.testConsumer(8988415576850624232L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getStageBatches(new StageId(10000000))); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getStageBatches(new StageId(10000000))); assertEquals(MaterialsError.UNKNOWN_STAGE_ID, contractException.getErrorType()); }); @@ -2233,8 +2369,10 @@ public void testGetStageBatchesByMaterialId() { batches = new LinkedHashSet<>(); map.put(materialId, batches); } - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(testMaterialsProducerId, materialId, randomGenerator.nextInt(100), - randomGenerator); + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo + .getBatchConstructionInfo(testMaterialsProducerId, materialId, + randomGenerator.nextInt(100), + randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); batches.add(batchId); materialsDataManager.moveBatchToStage(batchId, stageId); @@ -2285,19 +2423,23 @@ public void testGetStageBatchesByMaterialId() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); // if the stage id is null - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getStageBatchesByMaterialId(null, TestMaterialId.MATERIAL_1)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getStageBatchesByMaterialId(null, TestMaterialId.MATERIAL_1)); assertEquals(MaterialsError.NULL_STAGE_ID, contractException.getErrorType()); // if the stage id is unknown - contractException = assertThrows(ContractException.class, () -> materialsDataManager.getStageBatchesByMaterialId(new StageId(10000000), TestMaterialId.MATERIAL_1)); + contractException = assertThrows(ContractException.class, () -> materialsDataManager + .getStageBatchesByMaterialId(new StageId(10000000), TestMaterialId.MATERIAL_1)); assertEquals(MaterialsError.UNKNOWN_STAGE_ID, contractException.getErrorType()); // if the material id is null - contractException = assertThrows(ContractException.class, () -> materialsDataManager.getStageBatchesByMaterialId(new StageId(0), null)); + contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getStageBatchesByMaterialId(new StageId(0), null)); assertEquals(MaterialsError.NULL_MATERIAL_ID, contractException.getErrorType()); // if the material id is unknown - contractException = assertThrows(ContractException.class, () -> materialsDataManager.getStageBatchesByMaterialId(new StageId(0), TestMaterialId.getUnknownMaterialId())); + contractException = assertThrows(ContractException.class, () -> materialsDataManager + .getStageBatchesByMaterialId(new StageId(0), TestMaterialId.getUnknownMaterialId())); assertEquals(MaterialsError.UNKNOWN_MATERIAL_ID, contractException.getErrorType()); })); @@ -2328,14 +2470,16 @@ public void testGetStageProducer() { /* precondition test: if the stage id is null */ MaterialsActionSupport.testConsumer(3429442631390139742L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getStageProducer(null)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getStageProducer(null)); assertEquals(MaterialsError.NULL_STAGE_ID, contractException.getErrorType()); }); /* precondition test: if the stage id is unknown */ MaterialsActionSupport.testConsumer(8553021441594074433L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getStageProducer(new StageId(1000000000))); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getStageProducer(new StageId(1000000000))); assertEquals(MaterialsError.UNKNOWN_STAGE_ID, contractException.getErrorType()); }); @@ -2377,14 +2521,16 @@ public void testGetStages() { /* precondition test: if the materials producer id is null */ MaterialsActionSupport.testConsumer(8012112350970626114L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getStages(null)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getStages(null)); assertEquals(MaterialsError.NULL_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); /* precondition test: if the materials producer id is unknown */ MaterialsActionSupport.testConsumer(4013634140214782310L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getStages(TestMaterialsProducerId.getUnknownMaterialsProducerId())); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getStages(TestMaterialsProducerId.getUnknownMaterialsProducerId())); assertEquals(MaterialsError.UNKNOWN_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); } @@ -2408,11 +2554,13 @@ public void testIsStageOffered() { // precondition tests // if the stage id is null - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.isStageOffered(null)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.isStageOffered(null)); assertEquals(MaterialsError.NULL_STAGE_ID, contractException.getErrorType()); // if the stage id is unknown - contractException = assertThrows(ContractException.class, () -> materialsDataManager.isStageOffered(new StageId(1000000))); + contractException = assertThrows(ContractException.class, + () -> materialsDataManager.isStageOffered(new StageId(1000000))); assertEquals(MaterialsError.UNKNOWN_STAGE_ID, contractException.getErrorType()); })); @@ -2432,7 +2580,8 @@ public void testMaterialsProducerIdExists() { for (TestMaterialsProducerId testMaterialsProducerId : TestMaterialsProducerId.values()) { assertTrue(materialsDataManager.materialsProducerIdExists(testMaterialsProducerId)); } - assertFalse(materialsDataManager.materialsProducerIdExists(TestMaterialsProducerId.getUnknownMaterialsProducerId())); + assertFalse(materialsDataManager + .materialsProducerIdExists(TestMaterialsProducerId.getUnknownMaterialsProducerId())); assertFalse(materialsDataManager.materialsProducerIdExists(null)); }); @@ -2445,10 +2594,12 @@ public void testMaterialsProducerPropertyIdExists() { MaterialsActionSupport.testConsumer(8256309156804000329L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId.values()) { + for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId + .values()) { assertTrue(materialsDataManager.materialsProducerPropertyIdExists(testMaterialsProducerPropertyId)); } - assertFalse(materialsDataManager.materialsProducerPropertyIdExists(TestMaterialsProducerPropertyId.getUnknownMaterialsProducerPropertyId())); + assertFalse(materialsDataManager.materialsProducerPropertyIdExists( + TestMaterialsProducerPropertyId.getUnknownMaterialsProducerPropertyId())); assertFalse(materialsDataManager.materialsProducerPropertyIdExists(null)); }); } @@ -2497,7 +2648,8 @@ public void testMoveBatchToInventoryEvent() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); for (int i = 0; i < 40; i++) { - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(testMaterialsProducerId, TestMaterialId.getRandomMaterialId(randomGenerator), + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + testMaterialsProducerId, TestMaterialId.getRandomMaterialId(randomGenerator), randomGenerator.nextDouble() + 0.01, randomGenerator); materialsDataManager.addBatch(batchConstructionInfo); } @@ -2536,7 +2688,8 @@ public void testMoveBatchToInventoryEvent() { materialsDataManager.moveBatchToInventory(batchId); // show that the batch was returned to inventory assertFalse(materialsDataManager.getBatchStageId(batchId).isPresent()); - assertTrue(materialsDataManager.getInventoryBatches(testMaterialsProducerId).contains(batchId)); + assertTrue(materialsDataManager.getInventoryBatches(testMaterialsProducerId) + .contains(batchId)); // create the observation MultiKey multiKey = new MultiKey(c.getTime(), batchId, stageId); expectedObservations.add(multiKey); @@ -2559,14 +2712,16 @@ public void testMoveBatchToInventoryEvent() { /* precondition test: if the batch id is null */ MaterialsActionSupport.testConsumer(9033912130601526542L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.moveBatchToInventory(null)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.moveBatchToInventory(null)); assertEquals(MaterialsError.NULL_BATCH_ID, contractException.getErrorType()); }); /* precondition test: if the batch id is unknown */ MaterialsActionSupport.testConsumer(4357313141781993780L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.moveBatchToInventory(new BatchId(10000000))); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.moveBatchToInventory(new BatchId(10000000))); assertEquals(MaterialsError.UNKNOWN_BATCH_ID, contractException.getErrorType()); }); @@ -2575,10 +2730,12 @@ public void testMoveBatchToInventoryEvent() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 5.0, + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 5.0, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.moveBatchToInventory(batchId)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.moveBatchToInventory(batchId)); assertEquals(MaterialsError.BATCH_NOT_STAGED, contractException.getErrorType()); }); @@ -2587,13 +2744,15 @@ public void testMoveBatchToInventoryEvent() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 5.0, + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 5.0, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); materialsDataManager.moveBatchToStage(batchId, stageId); materialsDataManager.setStageOfferState(stageId, true); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.moveBatchToInventory(batchId)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.moveBatchToInventory(batchId)); assertEquals(MaterialsError.OFFERED_STAGE_UNALTERABLE, contractException.getErrorType()); }); @@ -2626,7 +2785,8 @@ public void testMoveBatchToStageEvent() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); for (int i = 0; i < 40; i++) { - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(testMaterialsProducerId, TestMaterialId.getRandomMaterialId(randomGenerator), + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + testMaterialsProducerId, TestMaterialId.getRandomMaterialId(randomGenerator), randomGenerator.nextDouble() + 0.01, randomGenerator); materialsDataManager.addBatch(batchConstructionInfo); } @@ -2679,7 +2839,8 @@ public void testMoveBatchToStageEvent() { MaterialsActionSupport.testConsumer(8929308420703752743L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.moveBatchToStage(null, stageId)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.moveBatchToStage(null, stageId)); assertEquals(MaterialsError.NULL_BATCH_ID, contractException.getErrorType()); }); @@ -2687,7 +2848,8 @@ public void testMoveBatchToStageEvent() { MaterialsActionSupport.testConsumer(2109267427404198126L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.moveBatchToStage(new BatchId(100000000), stageId)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.moveBatchToStage(new BatchId(100000000), stageId)); assertEquals(MaterialsError.UNKNOWN_BATCH_ID, contractException.getErrorType()); }); @@ -2696,12 +2858,14 @@ public void testMoveBatchToStageEvent() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_2, 5.6, + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_2, 5.6, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); materialsDataManager.moveBatchToStage(batchId, stageId); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.moveBatchToStage(batchId, stageId)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.moveBatchToStage(batchId, stageId)); assertEquals(MaterialsError.BATCH_ALREADY_STAGED, contractException.getErrorType()); }); @@ -2710,10 +2874,12 @@ public void testMoveBatchToStageEvent() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_2, 5.6, + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_2, 5.6, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.moveBatchToStage(batchId, null)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.moveBatchToStage(batchId, null)); assertEquals(MaterialsError.NULL_STAGE_ID, contractException.getErrorType()); }); @@ -2722,10 +2888,12 @@ public void testMoveBatchToStageEvent() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_2, 5.6, + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_2, 5.6, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.moveBatchToStage(batchId, new StageId(10000000))); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.moveBatchToStage(batchId, new StageId(10000000))); assertEquals(MaterialsError.UNKNOWN_STAGE_ID, contractException.getErrorType()); }); @@ -2734,12 +2902,14 @@ public void testMoveBatchToStageEvent() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_2, 5.6, + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_2, 5.6, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); materialsDataManager.setStageOfferState(stageId, true); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.moveBatchToStage(batchId, stageId)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.moveBatchToStage(batchId, stageId)); assertEquals(MaterialsError.OFFERED_STAGE_UNALTERABLE, contractException.getErrorType()); }); @@ -2751,11 +2921,13 @@ public void testMoveBatchToStageEvent() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_2, TestMaterialId.MATERIAL_2, 12, + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_2, TestMaterialId.MATERIAL_2, 12, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.moveBatchToStage(batchId, stageId)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.moveBatchToStage(batchId, stageId)); assertEquals(MaterialsError.BATCH_STAGED_TO_DIFFERENT_OWNER, contractException.getErrorType()); }); } @@ -2788,7 +2960,8 @@ public void testRemoveBatch() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); for (int i = 0; i < 50; i++) { - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(testMaterialsProducerId, TestMaterialId.getRandomMaterialId(randomGenerator), + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + testMaterialsProducerId, TestMaterialId.getRandomMaterialId(randomGenerator), randomGenerator.nextDouble(), randomGenerator); materialsDataManager.addBatch(batchConstructionInfo); } @@ -2800,7 +2973,8 @@ public void testRemoveBatch() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - List inventoryBatches = materialsDataManager.getInventoryBatches(TestMaterialsProducerId.MATERIALS_PRODUCER_1); + List inventoryBatches = materialsDataManager + .getInventoryBatches(TestMaterialsProducerId.MATERIALS_PRODUCER_1); for (BatchId batchId : inventoryBatches) { if (randomGenerator.nextBoolean()) { materialsDataManager.removeBatch(batchId); @@ -2830,14 +3004,16 @@ public void testRemoveBatch() { /* precondition test: if the batch id is null */ MaterialsActionSupport.testConsumer(6338675888020916426L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.removeBatch(null)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.removeBatch(null)); assertEquals(MaterialsError.NULL_BATCH_ID, contractException.getErrorType()); }); /* precondition test: if the batch id is unknown */ MaterialsActionSupport.testConsumer(3451796010171778050L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.removeBatch(new BatchId(100000))); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.removeBatch(new BatchId(100000))); assertEquals(MaterialsError.UNKNOWN_BATCH_ID, contractException.getErrorType()); }); @@ -2846,13 +3022,15 @@ public void testRemoveBatch() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); materialsDataManager.moveBatchToStage(batchId, stageId); materialsDataManager.setStageOfferState(stageId, true); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.removeBatch(batchId)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.removeBatch(batchId)); assertEquals(MaterialsError.OFFERED_STAGE_UNALTERABLE, contractException.getErrorType()); }); @@ -2895,8 +3073,10 @@ public void testRemoveStage() { StageId stageId = materialsDataManager.addStage(testMaterialsProducerId); int batchCount = randomGenerator.nextInt(3); for (int j = 0; j < batchCount; j++) { - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(testMaterialsProducerId, TestMaterialId.getRandomMaterialId(randomGenerator), - randomGenerator.nextDouble() + 0.01, randomGenerator); + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo + .getBatchConstructionInfo(testMaterialsProducerId, + TestMaterialId.getRandomMaterialId(randomGenerator), + randomGenerator.nextDouble() + 0.01, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); materialsDataManager.moveBatchToStage(batchId, stageId); } @@ -2976,14 +3156,16 @@ public void testRemoveStage() { /* precondition test: if the stage id is null */ MaterialsActionSupport.testConsumer(7585484363151799317L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.removeStage(null, false)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.removeStage(null, false)); assertEquals(MaterialsError.NULL_STAGE_ID, contractException.getErrorType()); }); /* precondition test: if the stage id is unknown */ MaterialsActionSupport.testConsumer(2068986583725856249L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.removeStage(new StageId(1000000), false)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.removeStage(new StageId(1000000), false)); assertEquals(MaterialsError.UNKNOWN_STAGE_ID, contractException.getErrorType()); }); @@ -2992,7 +3174,8 @@ public void testRemoveStage() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); materialsDataManager.setStageOfferState(stageId, true); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.removeStage(stageId, false)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.removeStage(stageId, false)); assertEquals(MaterialsError.OFFERED_STAGE_UNALTERABLE, contractException.getErrorType()); }); @@ -3010,7 +3193,8 @@ public void testBatchPropertyValueAssignmentEvent() { pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { c.subscribe(EventFilter.builder(BatchPropertyUpdateEvent.class).build(), (c2, e) -> { - MultiKey multiKey = new MultiKey(c2.getTime(), e.getBatchId(), e.getBatchPropertyId(), e.getPreviousPropertyValue(), e.getCurrentPropertyValue()); + MultiKey multiKey = new MultiKey(c2.getTime(), e.getBatchId(), e.getBatchPropertyId(), + e.getPreviousPropertyValue(), e.getCurrentPropertyValue()); actualObservations.add(multiKey); }); })); @@ -3022,7 +3206,8 @@ public void testBatchPropertyValueAssignmentEvent() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); for (int i = 0; i < 10; i++) { - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(testMaterialsProducerId, TestMaterialId.getRandomMaterialId(randomGenerator), + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + testMaterialsProducerId, TestMaterialId.getRandomMaterialId(randomGenerator), randomGenerator.nextDouble() + 0.01, randomGenerator); materialsDataManager.addBatch(batchConstructionInfo); } @@ -3040,17 +3225,23 @@ public void testBatchPropertyValueAssignmentEvent() { List inventoryBatches = materialsDataManager.getInventoryBatches(testMaterialsProducerId); for (BatchId batchId : inventoryBatches) { TestMaterialId batchMaterial = materialsDataManager.getBatchMaterial(batchId); - for (TestBatchPropertyId testBatchPropertyId : TestBatchPropertyId.getTestBatchPropertyIds(batchMaterial)) { + for (TestBatchPropertyId testBatchPropertyId : TestBatchPropertyId + .getTestBatchPropertyIds(batchMaterial)) { if (testBatchPropertyId.getPropertyDefinition().propertyValuesAreMutable()) { if (randomGenerator.nextBoolean()) { - Object newPropertyValue = testBatchPropertyId.getRandomPropertyValue(randomGenerator); - Object oldPropertyValue = materialsDataManager.getBatchPropertyValue(batchId, testBatchPropertyId); - expectedObservations.add(new MultiKey(c.getTime(), batchId, testBatchPropertyId, oldPropertyValue, newPropertyValue)); - materialsDataManager.setBatchPropertyValue(batchId, testBatchPropertyId, newPropertyValue); + Object newPropertyValue = testBatchPropertyId + .getRandomPropertyValue(randomGenerator); + Object oldPropertyValue = materialsDataManager.getBatchPropertyValue(batchId, + testBatchPropertyId); + expectedObservations.add(new MultiKey(c.getTime(), batchId, testBatchPropertyId, + oldPropertyValue, newPropertyValue)); + materialsDataManager.setBatchPropertyValue(batchId, testBatchPropertyId, + newPropertyValue); // show that the new property value is // present - assertEquals(newPropertyValue, materialsDataManager.getBatchPropertyValue(batchId, testBatchPropertyId)); + assertEquals(newPropertyValue, + materialsDataManager.getBatchPropertyValue(batchId, testBatchPropertyId)); } } } @@ -3073,7 +3264,8 @@ public void testBatchPropertyValueAssignmentEvent() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); BatchPropertyId batchPropertyId = TestBatchPropertyId.BATCH_PROPERTY_1_2_INTEGER_MUTABLE_NO_TRACK; Object propertyValue = 56; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.setBatchPropertyValue(null, batchPropertyId, propertyValue)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.setBatchPropertyValue(null, batchPropertyId, propertyValue)); assertEquals(MaterialsError.NULL_BATCH_ID, contractException.getErrorType()); }); @@ -3082,7 +3274,8 @@ public void testBatchPropertyValueAssignmentEvent() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); BatchPropertyId batchPropertyId = TestBatchPropertyId.BATCH_PROPERTY_1_2_INTEGER_MUTABLE_NO_TRACK; Object propertyValue = 56; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.setBatchPropertyValue(new BatchId(100000), batchPropertyId, propertyValue)); + ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager + .setBatchPropertyValue(new BatchId(100000), batchPropertyId, propertyValue)); assertEquals(MaterialsError.UNKNOWN_BATCH_ID, contractException.getErrorType()); }); @@ -3092,10 +3285,12 @@ public void testBatchPropertyValueAssignmentEvent() { RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); MaterialId materialId = TestMaterialId.MATERIAL_1; - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, materialId, 1.0, randomGenerator); + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, materialId, 1.0, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); Object propertyValue = 56; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.setBatchPropertyValue(batchId, null, propertyValue)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.setBatchPropertyValue(batchId, null, propertyValue)); assertEquals(PropertyError.NULL_PROPERTY_ID, contractException.getErrorType()); }); @@ -3105,11 +3300,13 @@ public void testBatchPropertyValueAssignmentEvent() { RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); MaterialId materialId = TestMaterialId.MATERIAL_1; - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, materialId, 1.0, randomGenerator); + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, materialId, 1.0, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); Object propertyValue = 56; ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.setBatchPropertyValue(batchId, TestBatchPropertyId.getUnknownBatchPropertyId(), propertyValue)); + () -> materialsDataManager.setBatchPropertyValue(batchId, + TestBatchPropertyId.getUnknownBatchPropertyId(), propertyValue)); assertEquals(PropertyError.UNKNOWN_PROPERTY_ID, contractException.getErrorType()); }); @@ -3119,10 +3316,12 @@ public void testBatchPropertyValueAssignmentEvent() { RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); MaterialId materialId = TestMaterialId.MATERIAL_1; - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, materialId, 1.0, randomGenerator); + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, materialId, 1.0, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.setBatchPropertyValue(batchId, TestBatchPropertyId.BATCH_PROPERTY_1_1_BOOLEAN_IMMUTABLE_NO_TRACK, false)); + () -> materialsDataManager.setBatchPropertyValue(batchId, + TestBatchPropertyId.BATCH_PROPERTY_1_1_BOOLEAN_IMMUTABLE_NO_TRACK, false)); assertEquals(PropertyError.IMMUTABLE_VALUE, contractException.getErrorType()); }); @@ -3132,10 +3331,12 @@ public void testBatchPropertyValueAssignmentEvent() { RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); MaterialId materialId = TestMaterialId.MATERIAL_1; - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, materialId, 1.0, randomGenerator); + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, materialId, 1.0, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); BatchPropertyId batchPropertyId = TestBatchPropertyId.BATCH_PROPERTY_1_2_INTEGER_MUTABLE_NO_TRACK; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.setBatchPropertyValue(batchId, batchPropertyId, null)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.setBatchPropertyValue(batchId, batchPropertyId, null)); assertEquals(PropertyError.NULL_PROPERTY_VALUE, contractException.getErrorType()); }); @@ -3147,10 +3348,12 @@ public void testBatchPropertyValueAssignmentEvent() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); MaterialId materialId = TestMaterialId.MATERIAL_1; RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(5751385676704973926L); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, materialId, 1.0, randomGenerator); + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, materialId, 1.0, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); BatchPropertyId batchPropertyId = TestBatchPropertyId.BATCH_PROPERTY_1_2_INTEGER_MUTABLE_NO_TRACK; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.setBatchPropertyValue(batchId, batchPropertyId, 12.4)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.setBatchPropertyValue(batchId, batchPropertyId, 12.4)); assertEquals(PropertyError.INCOMPATIBLE_VALUE, contractException.getErrorType()); }); @@ -3160,21 +3363,24 @@ public void testBatchPropertyValueAssignmentEvent() { MaterialId materialId = TestMaterialId.MATERIAL_1; StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, materialId, 1.0, randomGenerator); + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, materialId, 1.0, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); BatchPropertyId batchPropertyId = TestBatchPropertyId.BATCH_PROPERTY_1_2_INTEGER_MUTABLE_NO_TRACK; Object propertyValue = 56; StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); materialsDataManager.moveBatchToStage(batchId, stageId); materialsDataManager.setStageOfferState(stageId, true); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.setBatchPropertyValue(batchId, batchPropertyId, propertyValue)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.setBatchPropertyValue(batchId, batchPropertyId, propertyValue)); assertEquals(MaterialsError.OFFERED_STAGE_UNALTERABLE, contractException.getErrorType()); }); } @Test - @UnitTestMethod(name = "setMaterialsProducerPropertyValue", args = {MaterialsProducerId.class, MaterialsProducerPropertyId.class, Object.class}) + @UnitTestMethod(name = "setMaterialsProducerPropertyValue", args = { MaterialsProducerId.class, + MaterialsProducerPropertyId.class, Object.class }) public void testSetMaterialsProducerPropertyValue() { TestPluginData.Builder pluginBuilder = TestPluginData.builder(); @@ -3187,11 +3393,15 @@ public void testSetMaterialsProducerPropertyValue() { pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); for (TestMaterialsProducerId testMaterialsProducerId : TestMaterialsProducerId.values()) { - for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId.values()) { - EventFilter eventFilter = materialsDataManager.getEventFilterForMaterialsProducerPropertyUpdateEvent(testMaterialsProducerId, - testMaterialsProducerPropertyId); + for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId + .values()) { + EventFilter eventFilter = materialsDataManager + .getEventFilterForMaterialsProducerPropertyUpdateEvent(testMaterialsProducerId, + testMaterialsProducerPropertyId); c.subscribe(eventFilter, (c2, e) -> { - MultiKey multiKey = new MultiKey(c2.getTime(), e.getMaterialsProducerId(), e.getMaterialsProducerPropertyId(), e.getPreviousPropertyValue(), e.getCurrentPropertyValue()); + MultiKey multiKey = new MultiKey(c2.getTime(), e.getMaterialsProducerId(), + e.getMaterialsProducerPropertyId(), e.getPreviousPropertyValue(), + e.getCurrentPropertyValue()); actualObservations.add(multiKey); }); } @@ -3205,17 +3415,23 @@ public void testSetMaterialsProducerPropertyValue() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); - MaterialsProducerId materialsProducerId = TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator); - TestMaterialsProducerPropertyId testMaterialsProducerPropertyId = TestMaterialsProducerPropertyId.getRandomMutableMaterialsProducerPropertyId(randomGenerator); - Object oldValue = materialsDataManager.getMaterialsProducerPropertyValue(materialsProducerId, testMaterialsProducerPropertyId); + MaterialsProducerId materialsProducerId = TestMaterialsProducerId + .getRandomMaterialsProducerId(randomGenerator); + TestMaterialsProducerPropertyId testMaterialsProducerPropertyId = TestMaterialsProducerPropertyId + .getRandomMutableMaterialsProducerPropertyId(randomGenerator); + Object oldValue = materialsDataManager.getMaterialsProducerPropertyValue(materialsProducerId, + testMaterialsProducerPropertyId); Object newValue = testMaterialsProducerPropertyId.getRandomPropertyValue(randomGenerator); - materialsDataManager.setMaterialsProducerPropertyValue(materialsProducerId, testMaterialsProducerPropertyId, newValue); + materialsDataManager.setMaterialsProducerPropertyValue(materialsProducerId, + testMaterialsProducerPropertyId, newValue); // show that the new value is present - assertEquals(newValue, materialsDataManager.getMaterialsProducerPropertyValue(materialsProducerId, testMaterialsProducerPropertyId)); + assertEquals(newValue, materialsDataManager.getMaterialsProducerPropertyValue(materialsProducerId, + testMaterialsProducerPropertyId)); // record the expected observation - MultiKey multiKey = new MultiKey(c.getTime(), materialsProducerId, testMaterialsProducerPropertyId, oldValue, newValue); + MultiKey multiKey = new MultiKey(c.getTime(), materialsProducerId, testMaterialsProducerPropertyId, + oldValue, newValue); expectedObservations.add(multiKey); })); } @@ -3235,7 +3451,8 @@ public void testSetMaterialsProducerPropertyValue() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); MaterialsProducerPropertyId materialsProducerPropertyId = TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_2_INTEGER_MUTABLE_NO_TRACK; Object propertyValue = 5; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.setMaterialsProducerPropertyValue(null, materialsProducerPropertyId, propertyValue)); + ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager + .setMaterialsProducerPropertyValue(null, materialsProducerPropertyId, propertyValue)); assertEquals(MaterialsError.NULL_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); @@ -3245,7 +3462,9 @@ public void testSetMaterialsProducerPropertyValue() { MaterialsProducerPropertyId materialsProducerPropertyId = TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_2_INTEGER_MUTABLE_NO_TRACK; Object propertyValue = 5; ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.setMaterialsProducerPropertyValue(TestMaterialsProducerId.getUnknownMaterialsProducerId(), materialsProducerPropertyId, propertyValue)); + () -> materialsDataManager.setMaterialsProducerPropertyValue( + TestMaterialsProducerId.getUnknownMaterialsProducerId(), materialsProducerPropertyId, + propertyValue)); assertEquals(MaterialsError.UNKNOWN_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); @@ -3254,7 +3473,8 @@ public void testSetMaterialsProducerPropertyValue() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); MaterialsProducerId materialsProducerId = TestMaterialsProducerId.MATERIALS_PRODUCER_1; Object propertyValue = 5; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.setMaterialsProducerPropertyValue(materialsProducerId, null, propertyValue)); + ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager + .setMaterialsProducerPropertyValue(materialsProducerId, null, propertyValue)); assertEquals(PropertyError.NULL_PROPERTY_ID, contractException.getErrorType()); }); @@ -3266,7 +3486,8 @@ public void testSetMaterialsProducerPropertyValue() { MaterialsProducerId materialsProducerId = TestMaterialsProducerId.MATERIALS_PRODUCER_1; Object propertyValue = 5; ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.setMaterialsProducerPropertyValue(materialsProducerId, TestMaterialsProducerPropertyId.getUnknownMaterialsProducerPropertyId(), propertyValue)); + () -> materialsDataManager.setMaterialsProducerPropertyValue(materialsProducerId, + TestMaterialsProducerPropertyId.getUnknownMaterialsProducerPropertyId(), propertyValue)); assertEquals(PropertyError.UNKNOWN_PROPERTY_ID, contractException.getErrorType()); }); @@ -3275,8 +3496,10 @@ public void testSetMaterialsProducerPropertyValue() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); MaterialsProducerId materialsProducerId = TestMaterialsProducerId.MATERIALS_PRODUCER_1; Object propertyValue = 5; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.setMaterialsProducerPropertyValue(materialsProducerId, - TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_8_INTEGER_IMMUTABLE_NO_TRACK, propertyValue)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.setMaterialsProducerPropertyValue(materialsProducerId, + TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_8_INTEGER_IMMUTABLE_NO_TRACK, + propertyValue)); assertEquals(PropertyError.IMMUTABLE_VALUE, contractException.getErrorType()); }); @@ -3286,7 +3509,8 @@ public void testSetMaterialsProducerPropertyValue() { MaterialsProducerId materialsProducerId = TestMaterialsProducerId.MATERIALS_PRODUCER_1; MaterialsProducerPropertyId materialsProducerPropertyId = TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_2_INTEGER_MUTABLE_NO_TRACK; ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.setMaterialsProducerPropertyValue(materialsProducerId, materialsProducerPropertyId, null)); + () -> materialsDataManager.setMaterialsProducerPropertyValue(materialsProducerId, + materialsProducerPropertyId, null)); assertEquals(PropertyError.NULL_PROPERTY_VALUE, contractException.getErrorType()); }); @@ -3299,7 +3523,8 @@ public void testSetMaterialsProducerPropertyValue() { MaterialsProducerId materialsProducerId = TestMaterialsProducerId.MATERIALS_PRODUCER_1; MaterialsProducerPropertyId materialsProducerPropertyId = TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_2_INTEGER_MUTABLE_NO_TRACK; ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.setMaterialsProducerPropertyValue(materialsProducerId, materialsProducerPropertyId, 12.5)); + () -> materialsDataManager.setMaterialsProducerPropertyValue(materialsProducerId, + materialsProducerPropertyId, 12.5)); assertEquals(PropertyError.INCOMPATIBLE_VALUE, contractException.getErrorType()); }); @@ -3318,7 +3543,8 @@ public void testSetStageOfferState() { // have a agent observe stage creations pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { c.subscribe(EventFilter.builder(StageOfferUpdateEvent.class).build(), (c2, e) -> { - actualObservations.add(new MultiKey(c2.getTime(), e.getStageId(), e.isPreviousOfferState(), e.isCurrentOfferState())); + actualObservations.add( + new MultiKey(c2.getTime(), e.getStageId(), e.isPreviousOfferState(), e.isCurrentOfferState())); }); })); @@ -3367,14 +3593,16 @@ public void testSetStageOfferState() { /* precondition test: if the stage id is null */ MaterialsActionSupport.testConsumer(5384463547664747393L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.setStageOfferState(null, true)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.setStageOfferState(null, true)); assertEquals(MaterialsError.NULL_STAGE_ID, contractException.getErrorType()); }); /* precondition test: if the stage id is unknown */ MaterialsActionSupport.testConsumer(319106508275202491L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.setStageOfferState(new StageId(10000000), true)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.setStageOfferState(new StageId(10000000), true)); assertEquals(MaterialsError.UNKNOWN_STAGE_ID, contractException.getErrorType()); }); } @@ -3409,8 +3637,10 @@ public void testBatchContentShiftEvent() { RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); for (TestMaterialId testMaterialId : TestMaterialId.values()) { for (int i = 0; i < 10; i++) { - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(testMaterialsProducerId, testMaterialId, randomGenerator.nextDouble() + 0.1, - randomGenerator); + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo + .getBatchConstructionInfo(testMaterialsProducerId, testMaterialId, + randomGenerator.nextDouble() + 0.1, + randomGenerator); materialsDataManager.addBatch(batchConstructionInfo); } } @@ -3429,7 +3659,8 @@ public void testBatchContentShiftEvent() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); for (TestMaterialId testMaterialId : TestMaterialId.values()) { - List batches = materialsDataManager.getInventoryBatchesByMaterialId(materialsProducerId, testMaterialId); + List batches = materialsDataManager.getInventoryBatchesByMaterialId(materialsProducerId, + testMaterialId); int index1 = randomGenerator.nextInt(batches.size()); int index2 = randomGenerator.nextInt(batches.size()); if (index2 == index1) { @@ -3475,7 +3706,8 @@ public void testBatchContentShiftEvent() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, randomGenerator); BatchId destinationBatchId = materialsDataManager.addBatch(batchConstructionInfo); materialsDataManager.transferMaterialBetweenBatches(null, destinationBatchId, 0.1); @@ -3490,7 +3722,8 @@ public void testBatchContentShiftEvent() { RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); BatchId sourceBatchId = new BatchId(100000); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, randomGenerator); BatchId destinationBatchId = materialsDataManager.addBatch(batchConstructionInfo); materialsDataManager.transferMaterialBetweenBatches(sourceBatchId, destinationBatchId, 0.1); @@ -3504,7 +3737,8 @@ public void testBatchContentShiftEvent() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, randomGenerator); BatchId sourceBatchId = materialsDataManager.addBatch(batchConstructionInfo); BatchId destinationBatchId = null; @@ -3519,7 +3753,8 @@ public void testBatchContentShiftEvent() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, randomGenerator); BatchId sourceBatchId = materialsDataManager.addBatch(batchConstructionInfo); BatchId destinationBatchId = new BatchId(10000000); @@ -3536,7 +3771,8 @@ public void testBatchContentShiftEvent() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, randomGenerator); BatchId sourceBatchId = materialsDataManager.addBatch(batchConstructionInfo); BatchId destinationBatchId = sourceBatchId; @@ -3554,11 +3790,13 @@ public void testBatchContentShiftEvent() { RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, randomGenerator); BatchId sourceBatchId = materialsDataManager.addBatch(batchConstructionInfo); - batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_2, 1.0, randomGenerator); + batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_2, 1.0, randomGenerator); BatchId destinationBatchId = materialsDataManager.addBatch(batchConstructionInfo); materialsDataManager.transferMaterialBetweenBatches(sourceBatchId, destinationBatchId, 0.1); }); @@ -3574,10 +3812,12 @@ public void testBatchContentShiftEvent() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, randomGenerator); BatchId sourceBatchId = materialsDataManager.addBatch(batchConstructionInfo); - batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_2, TestMaterialId.MATERIAL_1, 1.0, randomGenerator); + batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_2, TestMaterialId.MATERIAL_1, 1.0, randomGenerator); BatchId destinationBatchId = materialsDataManager.addBatch(batchConstructionInfo); materialsDataManager.transferMaterialBetweenBatches(sourceBatchId, destinationBatchId, 0.1); }); @@ -3590,13 +3830,15 @@ public void testBatchContentShiftEvent() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, randomGenerator); BatchId sourceBatchId = materialsDataManager.addBatch(batchConstructionInfo); StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); materialsDataManager.moveBatchToStage(sourceBatchId, stageId); materialsDataManager.setStageOfferState(stageId, true); - batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, randomGenerator); + batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, randomGenerator); BatchId destinationBatchId = materialsDataManager.addBatch(batchConstructionInfo); materialsDataManager.transferMaterialBetweenBatches(sourceBatchId, destinationBatchId, 0.1); }); @@ -3611,10 +3853,12 @@ public void testBatchContentShiftEvent() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, randomGenerator); BatchId sourceBatchId = materialsDataManager.addBatch(batchConstructionInfo); - batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, randomGenerator); + batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, randomGenerator); BatchId destinationBatchId = materialsDataManager.addBatch(batchConstructionInfo); StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); materialsDataManager.moveBatchToStage(destinationBatchId, stageId); @@ -3630,12 +3874,15 @@ public void testBatchContentShiftEvent() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, randomGenerator); BatchId sourceBatchId = materialsDataManager.addBatch(batchConstructionInfo); - batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, randomGenerator); + batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, randomGenerator); BatchId destinationBatchId = materialsDataManager.addBatch(batchConstructionInfo); - materialsDataManager.transferMaterialBetweenBatches(sourceBatchId, destinationBatchId, Double.POSITIVE_INFINITY); + materialsDataManager.transferMaterialBetweenBatches(sourceBatchId, destinationBatchId, + Double.POSITIVE_INFINITY); }); assertEquals(MaterialsError.NON_FINITE_MATERIAL_AMOUNT, contractException.getErrorType()); }); @@ -3646,10 +3893,12 @@ public void testBatchContentShiftEvent() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, randomGenerator); BatchId sourceBatchId = materialsDataManager.addBatch(batchConstructionInfo); - batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, randomGenerator); + batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, randomGenerator); BatchId destinationBatchId = materialsDataManager.addBatch(batchConstructionInfo); materialsDataManager.transferMaterialBetweenBatches(sourceBatchId, destinationBatchId, -0.5); }); @@ -3665,10 +3914,12 @@ public void testBatchContentShiftEvent() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, randomGenerator); BatchId sourceBatchId = materialsDataManager.addBatch(batchConstructionInfo); - batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, randomGenerator); + batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, 1.0, randomGenerator); BatchId destinationBatchId = materialsDataManager.addBatch(batchConstructionInfo); materialsDataManager.transferMaterialBetweenBatches(sourceBatchId, destinationBatchId, 2.0); }); @@ -3684,10 +3935,13 @@ public void testBatchContentShiftEvent() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, Double.MAX_VALUE, randomGenerator); BatchId sourceBatchId = materialsDataManager.addBatch(batchConstructionInfo); - batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, Double.MAX_VALUE, randomGenerator); + batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialId.MATERIAL_1, Double.MAX_VALUE, + randomGenerator); BatchId destinationBatchId = materialsDataManager.addBatch(batchConstructionInfo); double amount = Double.MAX_VALUE / 2; materialsDataManager.transferMaterialBetweenBatches(sourceBatchId, destinationBatchId, amount); @@ -3709,7 +3963,8 @@ public void testTransferOfferedStage() { pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { c.subscribe(EventFilter.builder(StageMaterialsProducerUpdateEvent.class).build(), (c2, e) -> { - MultiKey multiKey = new MultiKey(c.getTime(), e.getStageId(), e.getPreviousMaterialsProducerId(), e.getCurrentMaterialsProducerId()); + MultiKey multiKey = new MultiKey(c.getTime(), e.getStageId(), e.getPreviousMaterialsProducerId(), + e.getCurrentMaterialsProducerId()); actualObservations.add(multiKey); }); @@ -3732,8 +3987,10 @@ public void testTransferOfferedStage() { for (int i = 0; i < stagesPerProducer; i++) { StageId stageId = materialsDataManager.addStage(testMaterialsProducerId); for (int j = 0; j < 3; j++) { - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(testMaterialsProducerId, TestMaterialId.getRandomMaterialId(randomGenerator), - randomGenerator.nextDouble() + 0.01, randomGenerator); + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo + .getBatchConstructionInfo(testMaterialsProducerId, + TestMaterialId.getRandomMaterialId(randomGenerator), + randomGenerator.nextDouble() + 0.01, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); materialsDataManager.moveBatchToStage(batchId, stageId); } @@ -3764,9 +4021,11 @@ public void testTransferOfferedStage() { // stage MaterialsProducerId stageProducer = materialsDataManager.getStageProducer(stageId); - List candidateProducers = new ArrayList<>(materialsDataManager.getMaterialsProducerIds()); + List candidateProducers = new ArrayList<>( + materialsDataManager.getMaterialsProducerIds()); candidateProducers.remove(stageProducer); - MaterialsProducerId altProducer = candidateProducers.get(randomGenerator.nextInt(candidateProducers.size())); + MaterialsProducerId altProducer = candidateProducers + .get(randomGenerator.nextInt(candidateProducers.size())); // transfer the stage materialsDataManager.transferOfferedStage(stageId, altProducer); @@ -3800,7 +4059,8 @@ public void testTransferOfferedStage() { StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); MaterialsProducerId altProducer = TestMaterialsProducerId.MATERIALS_PRODUCER_2; materialsDataManager.setStageOfferState(stageId, true); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.transferOfferedStage(null, altProducer)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.transferOfferedStage(null, altProducer)); assertEquals(MaterialsError.NULL_STAGE_ID, contractException.getErrorType()); }); @@ -3810,7 +4070,8 @@ public void testTransferOfferedStage() { StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); MaterialsProducerId altProducer = TestMaterialsProducerId.MATERIALS_PRODUCER_2; materialsDataManager.setStageOfferState(stageId, true); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.transferOfferedStage(new StageId(10000000), altProducer)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.transferOfferedStage(new StageId(10000000), altProducer)); assertEquals(MaterialsError.UNKNOWN_STAGE_ID, contractException.getErrorType()); }); @@ -3819,7 +4080,8 @@ public void testTransferOfferedStage() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); materialsDataManager.setStageOfferState(stageId, true); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.transferOfferedStage(stageId, null)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.transferOfferedStage(stageId, null)); assertEquals(MaterialsError.NULL_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); @@ -3829,7 +4091,8 @@ public void testTransferOfferedStage() { StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); materialsDataManager.setStageOfferState(stageId, true); ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.transferOfferedStage(stageId, TestMaterialsProducerId.getUnknownMaterialsProducerId())); + () -> materialsDataManager.transferOfferedStage(stageId, + TestMaterialsProducerId.getUnknownMaterialsProducerId())); assertEquals(MaterialsError.UNKNOWN_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); @@ -3840,7 +4103,8 @@ public void testTransferOfferedStage() { MaterialsProducerId altProducer = TestMaterialsProducerId.MATERIALS_PRODUCER_2; materialsDataManager.setStageOfferState(stageId, true); materialsDataManager.setStageOfferState(stageId, false); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.transferOfferedStage(stageId, altProducer)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.transferOfferedStage(stageId, altProducer)); assertEquals(MaterialsError.UNOFFERED_STAGE_NOT_TRANSFERABLE, contractException.getErrorType()); materialsDataManager.setStageOfferState(stageId, true); }); @@ -3854,14 +4118,16 @@ public void testTransferOfferedStage() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); materialsDataManager.setStageOfferState(stageId, true); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.transferOfferedStage(stageId, TestMaterialsProducerId.MATERIALS_PRODUCER_1)); + ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager + .transferOfferedStage(stageId, TestMaterialsProducerId.MATERIALS_PRODUCER_1)); assertEquals(MaterialsError.REFLEXIVE_STAGE_TRANSFER, contractException.getErrorType()); }); } @Test - @UnitTestMethod(name = "transferResourceToRegion", args = { MaterialsProducerId.class, ResourceId.class, RegionId.class, long.class }) + @UnitTestMethod(name = "transferResourceToRegion", args = { MaterialsProducerId.class, ResourceId.class, + RegionId.class, long.class }) public void testTransferResourceToRegion() { TestPluginData.Builder pluginBuilder = TestPluginData.builder(); double actionTime = 0; @@ -3886,18 +4152,22 @@ public void testTransferResourceToRegion() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); for (TestRegionId testRegionId : TestRegionId.values()) { for (TestResourceId testResourceId : TestResourceId.values()) { - EventFilter eventFilter = resourcesDataManager.getEventFilterForRegionResourceUpdateEvent(testResourceId, testRegionId); + EventFilter eventFilter = resourcesDataManager + .getEventFilterForRegionResourceUpdateEvent(testResourceId, testRegionId); c.subscribe(eventFilter, (c2, e) -> { - MultiKey multiKey = new MultiKey(c.getTime(), e.getResourceId(), e.getRegionId(), e.getPreviousResourceLevel(), e.getCurrentResourceLevel()); + MultiKey multiKey = new MultiKey(c.getTime(), e.getResourceId(), e.getRegionId(), + e.getPreviousResourceLevel(), e.getCurrentResourceLevel()); actualObservations.add(multiKey); }); } } for (TestResourceId testResourceId : TestResourceId.values()) { - EventFilter eventFilter = materialsDataManager.getEventFilterForMaterialsProducerResourceUpdateEvent(testResourceId); + EventFilter eventFilter = materialsDataManager + .getEventFilterForMaterialsProducerResourceUpdateEvent(testResourceId); c.subscribe(eventFilter, (c2, e) -> { - MultiKey multiKey = new MultiKey(c.getTime(), e.getResourceId(), e.getMaterialsProducerId(), e.getPreviousResourceLevel(), e.getCurrentResourceLevel()); + MultiKey multiKey = new MultiKey(c.getTime(), e.getResourceId(), e.getMaterialsProducerId(), + e.getPreviousResourceLevel(), e.getCurrentResourceLevel()); actualObservations.add(multiKey); }); } @@ -3916,7 +4186,8 @@ public void testTransferResourceToRegion() { StageId stageId = materialsDataManager.addStage(testMaterialsProducerId); long amount = (randomGenerator.nextInt(1000) + 100); materialsDataManager.convertStageToResource(stageId, testResourceId, amount); - MultiKey multiKey = new MultiKey(c.getTime(), testResourceId, testMaterialsProducerId, 0L, amount); + MultiKey multiKey = new MultiKey(c.getTime(), testResourceId, testMaterialsProducerId, 0L, + amount); expectedObservations.add(multiKey); } } @@ -3932,25 +4203,32 @@ public void testTransferResourceToRegion() { ResourcesDataManager resourcesDataManager = c.getDataManager(ResourcesDataManager.class); StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); - long materialsProducerResourceLevel = materialsDataManager.getMaterialsProducerResourceLevel(testMaterialsProducerId, testResourceId); + long materialsProducerResourceLevel = materialsDataManager + .getMaterialsProducerResourceLevel(testMaterialsProducerId, testResourceId); if (materialsProducerResourceLevel > 0) { long amountToTransfer = randomGenerator.nextInt((int) materialsProducerResourceLevel) + 1; TestRegionId regionId = TestRegionId.getRandomRegionId(randomGenerator); - long regionResourceLevel = resourcesDataManager.getRegionResourceLevel(regionId, testResourceId); - materialsDataManager.transferResourceToRegion(testMaterialsProducerId, testResourceId, regionId, amountToTransfer); + long regionResourceLevel = resourcesDataManager.getRegionResourceLevel(regionId, + testResourceId); + materialsDataManager.transferResourceToRegion(testMaterialsProducerId, testResourceId, regionId, + amountToTransfer); // show that the resource was transfered - long currentProducerResourceLevel = materialsDataManager.getMaterialsProducerResourceLevel(testMaterialsProducerId, testResourceId); - long currentRegionResourceLevel = resourcesDataManager.getRegionResourceLevel(regionId, testResourceId); + long currentProducerResourceLevel = materialsDataManager + .getMaterialsProducerResourceLevel(testMaterialsProducerId, testResourceId); + long currentRegionResourceLevel = resourcesDataManager.getRegionResourceLevel(regionId, + testResourceId); assertEquals(materialsProducerResourceLevel - amountToTransfer, currentProducerResourceLevel); assertEquals(regionResourceLevel + amountToTransfer, currentRegionResourceLevel); // record the expected observations - MultiKey multiKey = new MultiKey(c.getTime(), testResourceId, regionId, regionResourceLevel, currentRegionResourceLevel); + MultiKey multiKey = new MultiKey(c.getTime(), testResourceId, regionId, regionResourceLevel, + currentRegionResourceLevel); expectedObservations.add(multiKey); - multiKey = new MultiKey(c.getTime(), testResourceId, testMaterialsProducerId, materialsProducerResourceLevel, currentProducerResourceLevel); + multiKey = new MultiKey(c.getTime(), testResourceId, testMaterialsProducerId, + materialsProducerResourceLevel, currentProducerResourceLevel); expectedObservations.add(multiKey); } @@ -3977,7 +4255,8 @@ public void testTransferResourceToRegion() { long amountToTransfer = 45L; StageId stageId = materialsDataManager.addStage(materialsProducerId); materialsDataManager.convertStageToResource(stageId, resourceId, amountToTransfer); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.transferResourceToRegion(materialsProducerId, null, regionId, amountToTransfer)); + ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager + .transferResourceToRegion(materialsProducerId, null, regionId, amountToTransfer)); assertEquals(ResourceError.NULL_RESOURCE_ID, contractException.getErrorType()); }); @@ -3991,7 +4270,8 @@ public void testTransferResourceToRegion() { StageId stageId = materialsDataManager.addStage(materialsProducerId); materialsDataManager.convertStageToResource(stageId, resourceId, amountToTransfer); ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.transferResourceToRegion(materialsProducerId, TestResourceId.getUnknownResourceId(), regionId, amountToTransfer)); + () -> materialsDataManager.transferResourceToRegion(materialsProducerId, + TestResourceId.getUnknownResourceId(), regionId, amountToTransfer)); assertEquals(ResourceError.UNKNOWN_RESOURCE_ID, contractException.getErrorType()); }); @@ -4003,7 +4283,8 @@ public void testTransferResourceToRegion() { long amountToTransfer = 45L; StageId stageId = materialsDataManager.addStage(materialsProducerId); materialsDataManager.convertStageToResource(stageId, resourceId, amountToTransfer); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.transferResourceToRegion(materialsProducerId, resourceId, null, amountToTransfer)); + ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager + .transferResourceToRegion(materialsProducerId, resourceId, null, amountToTransfer)); assertEquals(RegionError.NULL_REGION_ID, contractException.getErrorType()); }); @@ -4016,7 +4297,8 @@ public void testTransferResourceToRegion() { StageId stageId = materialsDataManager.addStage(materialsProducerId); materialsDataManager.convertStageToResource(stageId, resourceId, amountToTransfer); ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.transferResourceToRegion(materialsProducerId, resourceId, TestRegionId.getUnknownRegionId(), amountToTransfer)); + () -> materialsDataManager.transferResourceToRegion(materialsProducerId, resourceId, + TestRegionId.getUnknownRegionId(), amountToTransfer)); assertEquals(RegionError.UNKNOWN_REGION_ID, contractException.getErrorType()); }); @@ -4029,7 +4311,8 @@ public void testTransferResourceToRegion() { long amountToTransfer = 45L; StageId stageId = materialsDataManager.addStage(materialsProducerId); materialsDataManager.convertStageToResource(stageId, resourceId, amountToTransfer); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.transferResourceToRegion(null, resourceId, regionId, amountToTransfer)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.transferResourceToRegion(null, resourceId, regionId, amountToTransfer)); assertEquals(MaterialsError.NULL_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); @@ -4043,7 +4326,9 @@ public void testTransferResourceToRegion() { StageId stageId = materialsDataManager.addStage(materialsProducerId); materialsDataManager.convertStageToResource(stageId, resourceId, amountToTransfer); ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.transferResourceToRegion(TestMaterialsProducerId.getUnknownMaterialsProducerId(), resourceId, regionId, amountToTransfer)); + () -> materialsDataManager.transferResourceToRegion( + TestMaterialsProducerId.getUnknownMaterialsProducerId(), resourceId, regionId, + amountToTransfer)); assertEquals(MaterialsError.UNKNOWN_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); @@ -4056,7 +4341,8 @@ public void testTransferResourceToRegion() { long amountToTransfer = 45L; StageId stageId = materialsDataManager.addStage(materialsProducerId); materialsDataManager.convertStageToResource(stageId, resourceId, amountToTransfer); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.transferResourceToRegion(materialsProducerId, resourceId, regionId, -1L)); + ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager + .transferResourceToRegion(materialsProducerId, resourceId, regionId, -1L)); assertEquals(ResourceError.NEGATIVE_RESOURCE_AMOUNT, contractException.getErrorType()); }); @@ -4073,7 +4359,8 @@ public void testTransferResourceToRegion() { StageId stageId = materialsDataManager.addStage(materialsProducerId); materialsDataManager.convertStageToResource(stageId, resourceId, amountToTransfer); ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.transferResourceToRegion(materialsProducerId, resourceId, regionId, amountToTransfer * 2)); + () -> materialsDataManager.transferResourceToRegion(materialsProducerId, resourceId, regionId, + amountToTransfer * 2)); assertEquals(ResourceError.INSUFFICIENT_RESOURCES_AVAILABLE, contractException.getErrorType()); }); @@ -4104,7 +4391,8 @@ public void testTransferResourceToRegion() { stageId = materialsDataManager.addStage(materialsProducerId); materialsDataManager.convertStageToResource(stageId, resourceId, hugeAmount); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.transferResourceToRegion(materialsProducerId, resourceId, regionId, hugeAmount)); + ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager + .transferResourceToRegion(materialsProducerId, resourceId, regionId, hugeAmount)); assertEquals(ResourceError.RESOURCE_ARITHMETIC_EXCEPTION, contractException.getErrorType()); }); @@ -4127,7 +4415,8 @@ public void testResourceIdAddition() { Set materialsProducerIds = materialsDataManager.getMaterialsProducerIds(); assertTrue(materialsProducerIds.size() > 0); for (MaterialsProducerId materialsProducerId : materialsProducerIds) { - long materialsProducerResourceLevel = materialsDataManager.getMaterialsProducerResourceLevel(materialsProducerId, newResourceId); + long materialsProducerResourceLevel = materialsDataManager + .getMaterialsProducerResourceLevel(materialsProducerId, newResourceId); assertEquals(0, materialsProducerResourceLevel); } }); @@ -4163,10 +4452,12 @@ public void testMaterialsDataManagerInitialState() { BatchId batchId = new BatchId(bId++); materialsBuilder.addBatch(batchId, testMaterialId, amount, testMaterialsProducerId); batches.add(batchId); - for (TestBatchPropertyId testBatchPropertyId : TestBatchPropertyId.getTestBatchPropertyIds(testMaterialId)) { + for (TestBatchPropertyId testBatchPropertyId : TestBatchPropertyId + .getTestBatchPropertyIds(testMaterialId)) { boolean required = testBatchPropertyId.getPropertyDefinition().getDefaultValue().isEmpty(); if (required || randomGenerator.nextBoolean()) { - materialsBuilder.setBatchPropertyValue(batchId, testBatchPropertyId, testBatchPropertyId.getRandomPropertyValue(randomGenerator)); + materialsBuilder.setBatchPropertyValue(batchId, testBatchPropertyId, + testBatchPropertyId.getRandomPropertyValue(randomGenerator)); } } @@ -4195,10 +4486,12 @@ public void testMaterialsDataManagerInitialState() { for (TestMaterialsProducerId testMaterialsProducerId : TestMaterialsProducerId.values()) { materialsBuilder.addMaterialsProducerId(testMaterialsProducerId); - for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId.values()) { + for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId + .values()) { boolean required = testMaterialsProducerPropertyId.getPropertyDefinition().getDefaultValue().isEmpty(); if (required || randomGenerator.nextBoolean()) { - materialsBuilder.setMaterialsProducerPropertyValue(testMaterialsProducerId, testMaterialsProducerPropertyId, + materialsBuilder.setMaterialsProducerPropertyValue(testMaterialsProducerId, + testMaterialsProducerPropertyId, testMaterialsProducerPropertyId.getRandomPropertyValue(randomGenerator)); } } @@ -4210,14 +4503,17 @@ public void testMaterialsDataManagerInitialState() { } } - for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId.values()) { - materialsBuilder.defineMaterialsProducerProperty(testMaterialsProducerPropertyId, testMaterialsProducerPropertyId.getPropertyDefinition()); + for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId + .values()) { + materialsBuilder.defineMaterialsProducerProperty(testMaterialsProducerPropertyId, + testMaterialsProducerPropertyId.getPropertyDefinition()); } for (TestMaterialId testMaterialId : TestMaterialId.values()) { Set testBatchPropertyIds = TestBatchPropertyId.getTestBatchPropertyIds(testMaterialId); for (TestBatchPropertyId testBatchPropertyId : testBatchPropertyIds) { - materialsBuilder.defineBatchProperty(testMaterialId, testBatchPropertyId, testBatchPropertyId.getPropertyDefinition()); + materialsBuilder.defineBatchProperty(testMaterialId, testBatchPropertyId, + testBatchPropertyId.getPropertyDefinition()); } } MaterialsPluginData materialsPluginData = materialsBuilder.build(); @@ -4287,10 +4583,12 @@ public void testMaterialsDataManagerInitialState() { assertTrue(resourcesDataManager.getResourceIds().containsAll(materialsPluginData.getResourceIds())); // show that the material property ids are correct - assertEquals(materialsPluginData.getMaterialsProducerPropertyIds(), materialsDataManager.getMaterialsProducerPropertyIds()); + assertEquals(materialsPluginData.getMaterialsProducerPropertyIds(), + materialsDataManager.getMaterialsProducerPropertyIds()); // show that the material producer property definitions are correct - for (MaterialsProducerPropertyId materialsProducerPropertyId : materialsPluginData.getMaterialsProducerPropertyIds()) { + for (MaterialsProducerPropertyId materialsProducerPropertyId : materialsPluginData + .getMaterialsProducerPropertyIds()) { assertEquals(materialsPluginData.getMaterialsProducerPropertyDefinition(materialsProducerPropertyId), materialsDataManager.getMaterialsProducerPropertyDefinition(materialsProducerPropertyId)); } @@ -4300,19 +4598,25 @@ public void testMaterialsDataManagerInitialState() { * that the initial resource levels are correct. */ for (MaterialsProducerId materialsProducerId : materialsPluginData.getMaterialsProducerIds()) { - for (MaterialsProducerPropertyId materialsProducerPropertyId : materialsPluginData.getMaterialsProducerPropertyIds()) { - Map materialsProducerPropertyValues = materialsPluginData.getMaterialsProducerPropertyValues(materialsProducerId); + for (MaterialsProducerPropertyId materialsProducerPropertyId : materialsPluginData + .getMaterialsProducerPropertyIds()) { + Map materialsProducerPropertyValues = materialsPluginData + .getMaterialsProducerPropertyValues(materialsProducerId); Object expectedValue = materialsProducerPropertyValues.get(materialsProducerPropertyId); if (expectedValue == null) { - PropertyDefinition propertyDefinition = materialsPluginData.getMaterialsProducerPropertyDefinition(materialsProducerPropertyId); + PropertyDefinition propertyDefinition = materialsPluginData + .getMaterialsProducerPropertyDefinition(materialsProducerPropertyId); expectedValue = propertyDefinition.getDefaultValue().get(); } - Object actualValue = materialsDataManager.getMaterialsProducerPropertyValue(materialsProducerId, materialsProducerPropertyId); + Object actualValue = materialsDataManager.getMaterialsProducerPropertyValue(materialsProducerId, + materialsProducerPropertyId); assertEquals(expectedValue, actualValue); } for (ResourceId resourceId : resourcesDataManager.getResourceIds()) { - Long expectedResourceLevel = materialsPluginData.getMaterialsProducerResourceLevel(materialsProducerId, resourceId); - Long actualResourceLevel = materialsDataManager.getMaterialsProducerResourceLevel(materialsProducerId, resourceId); + Long expectedResourceLevel = materialsPluginData + .getMaterialsProducerResourceLevel(materialsProducerId, resourceId); + Long actualResourceLevel = materialsDataManager + .getMaterialsProducerResourceLevel(materialsProducerId, resourceId); assertEquals(expectedResourceLevel, actualResourceLevel); } } @@ -4322,10 +4626,13 @@ public void testMaterialsDataManagerInitialState() { * definition. */ for (MaterialId materialId : materialsPluginData.getMaterialIds()) { - assertEquals(materialsPluginData.getBatchPropertyIds(materialId), materialsDataManager.getBatchPropertyIds(materialId)); + assertEquals(materialsPluginData.getBatchPropertyIds(materialId), + materialsDataManager.getBatchPropertyIds(materialId)); for (BatchPropertyId batchPropertyId : materialsPluginData.getBatchPropertyIds(materialId)) { - PropertyDefinition expectedPropertyDefinition = materialsPluginData.getBatchPropertyDefinition(materialId, batchPropertyId); - PropertyDefinition actualPropertyDefinition = materialsDataManager.getBatchPropertyDefinition(materialId, batchPropertyId); + PropertyDefinition expectedPropertyDefinition = materialsPluginData + .getBatchPropertyDefinition(materialId, batchPropertyId); + PropertyDefinition actualPropertyDefinition = materialsDataManager + .getBatchPropertyDefinition(materialId, batchPropertyId); assertEquals(expectedPropertyDefinition, actualPropertyDefinition); } } @@ -4355,7 +4662,8 @@ public void testMaterialsDataManagerInitialState() { MaterialId actualMaterialId = materialsDataManager.getBatchMaterial(batchId); assertEquals(expectedMaterialId, actualMaterialId); - MaterialsProducerId expectedMaterialsProducerId = materialsPluginData.getBatchMaterialsProducer(batchId); + MaterialsProducerId expectedMaterialsProducerId = materialsPluginData + .getBatchMaterialsProducer(batchId); MaterialsProducerId actualMaterialsProducerId = materialsDataManager.getBatchProducer(batchId); assertEquals(expectedMaterialsProducerId, actualMaterialsProducerId); @@ -4366,7 +4674,8 @@ public void testMaterialsDataManagerInitialState() { for (BatchPropertyId batchPropertyId : materialsPluginData.getBatchPropertyIds(expectedMaterialId)) { Object expectedValue = materialsPluginData.getBatchPropertyValues(batchId).get(batchPropertyId); if (expectedValue == null) { - PropertyDefinition propertyDefinition = materialsPluginData.getBatchPropertyDefinition(expectedMaterialId, batchPropertyId); + PropertyDefinition propertyDefinition = materialsPluginData + .getBatchPropertyDefinition(expectedMaterialId, batchPropertyId); expectedValue = propertyDefinition.getDefaultValue().get(); } Object actualValue = materialsDataManager.getBatchPropertyValue(batchId, batchPropertyId); @@ -4391,7 +4700,8 @@ public void testMaterialsDataManagerInitialState() { for (StageId stageId : materialsPluginData.getStageIds()) { - MaterialsProducerId expectedMaterialsProducerId = materialsPluginData.getStageMaterialsProducer(stageId); + MaterialsProducerId expectedMaterialsProducerId = materialsPluginData + .getStageMaterialsProducer(stageId); MaterialsProducerId actualMaterialsProducerId = materialsDataManager.getStageProducer(stageId); assertEquals(expectedMaterialsProducerId, actualMaterialsProducerId); @@ -4449,16 +4759,18 @@ public void testAddMaterialsProducer() { assertFalse(materialsDataManager.materialsProducerIdExists(newMaterialsProducerId)); MaterialsProducerConstructionData.Builder builder // - = MaterialsProducerConstructionData .builder()// - .setMaterialsProducerId(newMaterialsProducerId);// + = MaterialsProducerConstructionData.builder()// + .setMaterialsProducerId(newMaterialsProducerId);// Map expectedPropertyValues = new LinkedHashMap<>(); - for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId.values()) { + for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId + .values()) { Optional optional = testMaterialsProducerPropertyId.getPropertyDefinition().getDefaultValue(); if (optional.isPresent()) { expectedPropertyValues.put(testMaterialsProducerPropertyId, optional.get()); } else { - Object randomPropertyValue = testMaterialsProducerPropertyId.getRandomPropertyValue(randomGenerator); + Object randomPropertyValue = testMaterialsProducerPropertyId + .getRandomPropertyValue(randomGenerator); builder.setMaterialsProducerPropertyValue(testMaterialsProducerPropertyId, randomPropertyValue); expectedPropertyValues.put(testMaterialsProducerPropertyId, randomPropertyValue); } @@ -4471,14 +4783,18 @@ public void testAddMaterialsProducer() { double expectedTime = c.getTime(); int propertyTimeIsCurrentTimeCount = 0; - for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId.values()) { + for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId + .values()) { Object expectedValue = expectedPropertyValues.get(testMaterialsProducerPropertyId); - Object actualValue = materialsDataManager.getMaterialsProducerPropertyValue(newMaterialsProducerId, testMaterialsProducerPropertyId); + Object actualValue = materialsDataManager.getMaterialsProducerPropertyValue(newMaterialsProducerId, + testMaterialsProducerPropertyId); assertEquals(expectedValue, actualValue); - double actualTime = materialsDataManager.getMaterialsProducerPropertyTime(newMaterialsProducerId, testMaterialsProducerPropertyId); + double actualTime = materialsDataManager.getMaterialsProducerPropertyTime(newMaterialsProducerId, + testMaterialsProducerPropertyId); - boolean defaultValueExists = testMaterialsProducerPropertyId.getPropertyDefinition().getDefaultValue().isPresent(); + boolean defaultValueExists = testMaterialsProducerPropertyId.getPropertyDefinition().getDefaultValue() + .isPresent(); if (defaultValueExists) { assertEquals(0.0, actualTime); @@ -4491,9 +4807,11 @@ public void testAddMaterialsProducer() { assertTrue(propertyTimeIsCurrentTimeCount > 0); long expectedLevel = 0; for (TestResourceId testResourceId : TestResourceId.values()) { - long actualLevel = materialsDataManager.getMaterialsProducerResourceLevel(newMaterialsProducerId, testResourceId); + long actualLevel = materialsDataManager.getMaterialsProducerResourceLevel(newMaterialsProducerId, + testResourceId); assertEquals(expectedLevel, actualLevel); - double actualTime = materialsDataManager.getMaterialsProducerResourceTime(newMaterialsProducerId, testResourceId); + double actualTime = materialsDataManager.getMaterialsProducerResourceTime(newMaterialsProducerId, + testResourceId); assertEquals(expectedTime, actualTime); } @@ -4520,12 +4838,14 @@ public void testAddMaterialsProducer() { MaterialsProducerConstructionData.Builder builder = // MaterialsProducerConstructionData.builder(); builder.setMaterialsProducerId(TestMaterialsProducerId.MATERIALS_PRODUCER_1); - for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId.getPropertiesWithoutDefaultValues()) { + for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId + .getPropertiesWithoutDefaultValues()) { Object randomPropertyValue = testMaterialsProducerPropertyId.getRandomPropertyValue(randomGenerator); builder.setMaterialsProducerPropertyValue(testMaterialsProducerPropertyId, randomPropertyValue); } MaterialsProducerConstructionData materialsProducerConstructionData = builder.build(); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.addMaterialsProducer(materialsProducerConstructionData)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.addMaterialsProducer(materialsProducerConstructionData)); assertEquals(MaterialsError.DUPLICATE_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); @@ -4537,8 +4857,10 @@ public void testAddMaterialsProducer() { MaterialsActionSupport.testConsumer(1777796798041842032L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); MaterialsProducerId newMaterialsProducerId = TestMaterialsProducerId.getUnknownMaterialsProducerId(); - MaterialsProducerConstructionData materialsProducerConstructionData = MaterialsProducerConstructionData.builder().setMaterialsProducerId(newMaterialsProducerId).build(); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.addMaterialsProducer(materialsProducerConstructionData)); + MaterialsProducerConstructionData materialsProducerConstructionData = MaterialsProducerConstructionData + .builder().setMaterialsProducerId(newMaterialsProducerId).build(); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.addMaterialsProducer(materialsProducerConstructionData)); assertEquals(PropertyError.INSUFFICIENT_PROPERTY_VALUE_ASSIGNMENT, contractException.getErrorType()); }); @@ -4555,16 +4877,19 @@ public void testAddMaterialsProducer() { MaterialsProducerConstructionData.Builder builder = // MaterialsProducerConstructionData.builder(); builder.setMaterialsProducerId(TestMaterialsProducerId.getUnknownMaterialsProducerId()); - for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId.getPropertiesWithoutDefaultValues()) { + for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId + .getPropertiesWithoutDefaultValues()) { Object randomPropertyValue = testMaterialsProducerPropertyId.getRandomPropertyValue(randomGenerator); builder.setMaterialsProducerPropertyValue(testMaterialsProducerPropertyId, randomPropertyValue); } - builder.setMaterialsProducerPropertyValue(TestMaterialsProducerPropertyId.getUnknownMaterialsProducerPropertyId(), 10); + builder.setMaterialsProducerPropertyValue( + TestMaterialsProducerPropertyId.getUnknownMaterialsProducerPropertyId(), 10); MaterialsProducerConstructionData materialsProducerConstructionData = builder.build(); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.addMaterialsProducer(materialsProducerConstructionData)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.addMaterialsProducer(materialsProducerConstructionData)); assertEquals(PropertyError.UNKNOWN_PROPERTY_ID, contractException.getErrorType()); }); @@ -4589,31 +4914,37 @@ public void testDefineBatchProperty() { pluginBuilder.addTestActorPlan("actor", new TestActorPlan(1, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - PropertyDefinition propertyDefinition = PropertyDefinition.builder().setType(Integer.class).setDefaultValue(12).build(); + PropertyDefinition propertyDefinition = PropertyDefinition.builder().setType(Integer.class) + .setDefaultValue(12).build(); BatchPropertyId batchPropertyId = TestBatchPropertyId.getUnknownBatchPropertyId(); MaterialId materialId = TestMaterialId.MATERIAL_1; - BatchPropertyDefinitionInitialization batchPropertyDefinitionInitialization = BatchPropertyDefinitionInitialization .builder().setMaterialId(materialId).setPropertyId(batchPropertyId) - .setPropertyDefinition(propertyDefinition).build(); + BatchPropertyDefinitionInitialization batchPropertyDefinitionInitialization = BatchPropertyDefinitionInitialization + .builder().setMaterialId(materialId).setPropertyId(batchPropertyId) + .setPropertyDefinition(propertyDefinition).build(); materialsDataManager.defineBatchProperty(batchPropertyDefinitionInitialization); MultiKey multiKey = new MultiKey(c.getTime(), materialId, batchPropertyId); expectedObservations.add(multiKey); assertTrue(materialsDataManager.getBatchPropertyIds(materialId).contains(batchPropertyId)); - PropertyDefinition actualPropertyDefinition = materialsDataManager.getBatchPropertyDefinition(materialId, batchPropertyId); + PropertyDefinition actualPropertyDefinition = materialsDataManager.getBatchPropertyDefinition(materialId, + batchPropertyId); assertEquals(propertyDefinition, actualPropertyDefinition); })); pluginBuilder.addTestActorPlan("actor", new TestActorPlan(2, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - PropertyDefinition propertyDefinition = PropertyDefinition.builder().setType(String.class).setDefaultValue("default").build(); + PropertyDefinition propertyDefinition = PropertyDefinition.builder().setType(String.class) + .setDefaultValue("default").build(); BatchPropertyId batchPropertyId = TestBatchPropertyId.getUnknownBatchPropertyId(); MaterialId materialId = TestMaterialId.MATERIAL_2; - BatchPropertyDefinitionInitialization batchPropertyDefinitionInitialization = BatchPropertyDefinitionInitialization .builder().setMaterialId(materialId).setPropertyId(batchPropertyId) - .setPropertyDefinition(propertyDefinition).build(); + BatchPropertyDefinitionInitialization batchPropertyDefinitionInitialization = BatchPropertyDefinitionInitialization + .builder().setMaterialId(materialId).setPropertyId(batchPropertyId) + .setPropertyDefinition(propertyDefinition).build(); materialsDataManager.defineBatchProperty(batchPropertyDefinitionInitialization); MultiKey multiKey = new MultiKey(c.getTime(), materialId, batchPropertyId); expectedObservations.add(multiKey); assertTrue(materialsDataManager.getBatchPropertyIds(materialId).contains(batchPropertyId)); - PropertyDefinition actualPropertyDefinition = materialsDataManager.getBatchPropertyDefinition(materialId, batchPropertyId); + PropertyDefinition actualPropertyDefinition = materialsDataManager.getBatchPropertyDefinition(materialId, + batchPropertyId); assertEquals(propertyDefinition, actualPropertyDefinition); })); @@ -4631,17 +4962,19 @@ public void testDefineBatchProperty() { */ MaterialsActionSupport.testConsumer(3376758409444036216L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - PropertyDefinition propertyDefinition = PropertyDefinition.builder().setType(Integer.class).setDefaultValue(12).build(); + PropertyDefinition propertyDefinition = PropertyDefinition.builder().setType(Integer.class) + .setDefaultValue(12).build(); BatchPropertyId batchPropertyId = TestBatchPropertyId.getUnknownBatchPropertyId(); MaterialId materialId = TestMaterialId.getUnknownMaterialId(); BatchPropertyDefinitionInitialization batchPropertyDefinitionInitialization = // - BatchPropertyDefinitionInitialization .builder()// - .setMaterialId(materialId)// - .setPropertyId(batchPropertyId)// - .setPropertyDefinition(propertyDefinition)// - .build(); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.defineBatchProperty(batchPropertyDefinitionInitialization)); + BatchPropertyDefinitionInitialization.builder()// + .setMaterialId(materialId)// + .setPropertyId(batchPropertyId)// + .setPropertyDefinition(propertyDefinition)// + .build(); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.defineBatchProperty(batchPropertyDefinitionInitialization)); assertEquals(MaterialsError.UNKNOWN_MATERIAL_ID, contractException.getErrorType()); }); @@ -4650,18 +4983,20 @@ public void testDefineBatchProperty() { */ MaterialsActionSupport.testConsumer(7152319084879177681L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - PropertyDefinition propertyDefinition = PropertyDefinition.builder().setType(Integer.class).setDefaultValue(12).build(); + PropertyDefinition propertyDefinition = PropertyDefinition.builder().setType(Integer.class) + .setDefaultValue(12).build(); BatchPropertyId batchPropertyId = TestBatchPropertyId.BATCH_PROPERTY_1_3_DOUBLE_MUTABLE_NO_TRACK; MaterialId materialId = TestMaterialId.MATERIAL_1; BatchPropertyDefinitionInitialization batchPropertyDefinitionInitialization = // - BatchPropertyDefinitionInitialization .builder()// - .setMaterialId(materialId)// - .setPropertyId(batchPropertyId)// - .setPropertyDefinition(propertyDefinition)// - .build(); + BatchPropertyDefinitionInitialization.builder()// + .setMaterialId(materialId)// + .setPropertyId(batchPropertyId)// + .setPropertyDefinition(propertyDefinition)// + .build(); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.defineBatchProperty(batchPropertyDefinitionInitialization)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.defineBatchProperty(batchPropertyDefinitionInitialization)); assertEquals(PropertyError.DUPLICATE_PROPERTY_DEFINITION, contractException.getErrorType()); }); @@ -4674,14 +5009,15 @@ public void testDefineBatchProperty() { MaterialId materialId = TestMaterialId.MATERIAL_1; BatchPropertyDefinitionInitialization batchPropertyDefinitionInitialization = // - BatchPropertyDefinitionInitialization .builder()// - .setMaterialId(materialId)// - .setPropertyId(batchPropertyId)// - .setPropertyDefinition(propertyDefinition)// - .addPropertyValue(new BatchId(765), 88)// - .build(); - - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.defineBatchProperty(batchPropertyDefinitionInitialization)); + BatchPropertyDefinitionInitialization.builder()// + .setMaterialId(materialId)// + .setPropertyId(batchPropertyId)// + .setPropertyDefinition(propertyDefinition)// + .addPropertyValue(new BatchId(765), 88)// + .build(); + + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.defineBatchProperty(batchPropertyDefinitionInitialization)); assertEquals(MaterialsError.UNKNOWN_BATCH_ID, contractException.getErrorType()); }); @@ -4695,18 +5031,20 @@ public void testDefineBatchProperty() { BatchPropertyId batchPropertyId = TestBatchPropertyId.getUnknownBatchPropertyId(); MaterialId materialId = TestMaterialId.MATERIAL_1; MaterialId altMaterialId = TestMaterialId.MATERIAL_2; - BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo(TestMaterialsProducerId.MATERIALS_PRODUCER_1, altMaterialId, 345.0, randomGenerator); + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo.getBatchConstructionInfo( + TestMaterialsProducerId.MATERIALS_PRODUCER_1, altMaterialId, 345.0, randomGenerator); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); BatchPropertyDefinitionInitialization batchPropertyDefinitionInitialization = // - BatchPropertyDefinitionInitialization .builder()// - .setMaterialId(materialId)// - .setPropertyId(batchPropertyId)// - .setPropertyDefinition(propertyDefinition)// - .addPropertyValue(batchId, 45)// - .build(); - - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.defineBatchProperty(batchPropertyDefinitionInitialization)); + BatchPropertyDefinitionInitialization.builder()// + .setMaterialId(materialId)// + .setPropertyId(batchPropertyId)// + .setPropertyDefinition(propertyDefinition)// + .addPropertyValue(batchId, 45)// + .build(); + + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.defineBatchProperty(batchPropertyDefinitionInitialization)); assertEquals(MaterialsError.MATERIAL_TYPE_MISMATCH, contractException.getErrorType()); }); @@ -4758,7 +5096,8 @@ public void testAddMaterialId() { */ MaterialsActionSupport.testConsumer(801838096204060748L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.addMaterialId(null)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.addMaterialId(null)); assertEquals(MaterialsError.NULL_MATERIAL_ID, contractException.getErrorType()); }); @@ -4767,14 +5106,16 @@ public void testAddMaterialId() { */ MaterialsActionSupport.testConsumer(4318358212946306160L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.addMaterialId(TestMaterialId.MATERIAL_1)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.addMaterialId(TestMaterialId.MATERIAL_1)); assertEquals(MaterialsError.DUPLICATE_MATERIAL, contractException.getErrorType()); }); } @Test - @UnitTestMethod(name = "getEventFilterForMaterialsProducerPropertyUpdateEvent", args = { MaterialsProducerId.class, MaterialsProducerPropertyId.class }) + @UnitTestMethod(name = "getEventFilterForMaterialsProducerPropertyUpdateEvent", args = { MaterialsProducerId.class, + MaterialsProducerPropertyId.class }) public void testGetEventFilterForMaterialsProducerPropertyUpdateEvent_Producer_Property() { TestPluginData.Builder pluginBuilder = TestPluginData.builder(); @@ -4784,12 +5125,18 @@ public void testGetEventFilterForMaterialsProducerPropertyUpdateEvent_Producer_P Set actualObservations = new LinkedHashSet<>(); Set> selectedPairs = new LinkedHashSet<>(); - selectedPairs.add(new Pair<>(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_1_BOOLEAN_MUTABLE_NO_TRACK)); - selectedPairs.add(new Pair<>(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_2_INTEGER_MUTABLE_NO_TRACK)); - selectedPairs.add(new Pair<>(TestMaterialsProducerId.MATERIALS_PRODUCER_1, TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_3_DOUBLE_MUTABLE_NO_TRACK)); - selectedPairs.add(new Pair<>(TestMaterialsProducerId.MATERIALS_PRODUCER_2, TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_4_BOOLEAN_MUTABLE_TRACK)); - selectedPairs.add(new Pair<>(TestMaterialsProducerId.MATERIALS_PRODUCER_2, TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_5_INTEGER_MUTABLE_TRACK)); - selectedPairs.add(new Pair<>(TestMaterialsProducerId.MATERIALS_PRODUCER_2, TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_6_DOUBLE_MUTABLE_TRACK)); + selectedPairs.add(new Pair<>(TestMaterialsProducerId.MATERIALS_PRODUCER_1, + TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_1_BOOLEAN_MUTABLE_NO_TRACK)); + selectedPairs.add(new Pair<>(TestMaterialsProducerId.MATERIALS_PRODUCER_1, + TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_2_INTEGER_MUTABLE_NO_TRACK)); + selectedPairs.add(new Pair<>(TestMaterialsProducerId.MATERIALS_PRODUCER_1, + TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_3_DOUBLE_MUTABLE_NO_TRACK)); + selectedPairs.add(new Pair<>(TestMaterialsProducerId.MATERIALS_PRODUCER_2, + TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_4_BOOLEAN_MUTABLE_TRACK)); + selectedPairs.add(new Pair<>(TestMaterialsProducerId.MATERIALS_PRODUCER_2, + TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_5_INTEGER_MUTABLE_TRACK)); + selectedPairs.add(new Pair<>(TestMaterialsProducerId.MATERIALS_PRODUCER_2, + TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_6_DOUBLE_MUTABLE_TRACK)); // have an agent observe all changes to the selected producer/property // pairs @@ -4799,10 +5146,12 @@ public void testGetEventFilterForMaterialsProducerPropertyUpdateEvent_Producer_P for (Pair pair : selectedPairs) { MaterialsProducerId materialsProducerId = pair.getFirst(); MaterialsProducerPropertyId materialsProducerPropertyId = pair.getSecond(); - EventFilter eventFilter = materialsDataManager.getEventFilterForMaterialsProducerPropertyUpdateEvent(materialsProducerId, - materialsProducerPropertyId); + EventFilter eventFilter = materialsDataManager + .getEventFilterForMaterialsProducerPropertyUpdateEvent(materialsProducerId, + materialsProducerPropertyId); c.subscribe(eventFilter, (c2, e) -> { - MultiKey multiKey = new MultiKey(c2.getTime(), e.getMaterialsProducerId(), e.getMaterialsProducerPropertyId()); + MultiKey multiKey = new MultiKey(c2.getTime(), e.getMaterialsProducerId(), + e.getMaterialsProducerPropertyId()); actualObservations.add(multiKey); }); } @@ -4815,12 +5164,16 @@ public void testGetEventFilterForMaterialsProducerPropertyUpdateEvent_Producer_P StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); - MaterialsProducerId materialsProducerId = TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator); - TestMaterialsProducerPropertyId testMaterialsProducerPropertyId = TestMaterialsProducerPropertyId.getRandomMutableMaterialsProducerPropertyId(randomGenerator); + MaterialsProducerId materialsProducerId = TestMaterialsProducerId + .getRandomMaterialsProducerId(randomGenerator); + TestMaterialsProducerPropertyId testMaterialsProducerPropertyId = TestMaterialsProducerPropertyId + .getRandomMutableMaterialsProducerPropertyId(randomGenerator); Object newValue = testMaterialsProducerPropertyId.getRandomPropertyValue(randomGenerator); - materialsDataManager.setMaterialsProducerPropertyValue(materialsProducerId, testMaterialsProducerPropertyId, newValue); + materialsDataManager.setMaterialsProducerPropertyValue(materialsProducerId, + testMaterialsProducerPropertyId, newValue); - Pair pair = new Pair<>(materialsProducerId, testMaterialsProducerPropertyId); + Pair pair = new Pair<>(materialsProducerId, + testMaterialsProducerPropertyId); if (selectedPairs.contains(pair)) { MultiKey multiKey = new MultiKey(c.getTime(), materialsProducerId, testMaterialsProducerPropertyId); expectedObservations.add(multiKey); @@ -4844,7 +5197,8 @@ public void testGetEventFilterForMaterialsProducerPropertyUpdateEvent_Producer_P MaterialsProducerId materialsProducerId = null; MaterialsProducerPropertyId materialsProducerPropertyId = TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_2_INTEGER_MUTABLE_NO_TRACK; ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.getEventFilterForMaterialsProducerPropertyUpdateEvent(materialsProducerId, materialsProducerPropertyId)); + () -> materialsDataManager.getEventFilterForMaterialsProducerPropertyUpdateEvent( + materialsProducerId, materialsProducerPropertyId)); assertEquals(MaterialsError.NULL_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); @@ -4854,7 +5208,8 @@ public void testGetEventFilterForMaterialsProducerPropertyUpdateEvent_Producer_P MaterialsProducerPropertyId materialsProducerPropertyId = TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_2_INTEGER_MUTABLE_NO_TRACK; MaterialsProducerId materialsProducerId = TestMaterialsProducerId.getUnknownMaterialsProducerId(); ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.getEventFilterForMaterialsProducerPropertyUpdateEvent(materialsProducerId, materialsProducerPropertyId)); + () -> materialsDataManager.getEventFilterForMaterialsProducerPropertyUpdateEvent( + materialsProducerId, materialsProducerPropertyId)); assertEquals(MaterialsError.UNKNOWN_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); @@ -4864,7 +5219,8 @@ public void testGetEventFilterForMaterialsProducerPropertyUpdateEvent_Producer_P MaterialsProducerPropertyId materialsProducerPropertyId = null; MaterialsProducerId materialsProducerId = TestMaterialsProducerId.MATERIALS_PRODUCER_1; ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.getEventFilterForMaterialsProducerPropertyUpdateEvent(materialsProducerId, materialsProducerPropertyId)); + () -> materialsDataManager.getEventFilterForMaterialsProducerPropertyUpdateEvent( + materialsProducerId, materialsProducerPropertyId)); assertEquals(PropertyError.NULL_PROPERTY_ID, contractException.getErrorType()); }); @@ -4873,10 +5229,12 @@ public void testGetEventFilterForMaterialsProducerPropertyUpdateEvent_Producer_P */ MaterialsActionSupport.testConsumer(3228733928828489429L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - MaterialsProducerPropertyId materialsProducerPropertyId = TestMaterialsProducerPropertyId.getUnknownMaterialsProducerPropertyId(); + MaterialsProducerPropertyId materialsProducerPropertyId = TestMaterialsProducerPropertyId + .getUnknownMaterialsProducerPropertyId(); MaterialsProducerId materialsProducerId = TestMaterialsProducerId.MATERIALS_PRODUCER_1; ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.getEventFilterForMaterialsProducerPropertyUpdateEvent(materialsProducerId, materialsProducerPropertyId)); + () -> materialsDataManager.getEventFilterForMaterialsProducerPropertyUpdateEvent( + materialsProducerId, materialsProducerPropertyId)); assertEquals(PropertyError.UNKNOWN_PROPERTY_ID, contractException.getErrorType()); }); @@ -4896,9 +5254,11 @@ public void testGetEventFilterForMaterialsProducerPropertyUpdateEvent() { pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - EventFilter eventFilter = materialsDataManager.getEventFilterForMaterialsProducerPropertyUpdateEvent(); + EventFilter eventFilter = materialsDataManager + .getEventFilterForMaterialsProducerPropertyUpdateEvent(); c.subscribe(eventFilter, (c2, e) -> { - MultiKey multiKey = new MultiKey(c2.getTime(), e.getMaterialsProducerId(), e.getMaterialsProducerPropertyId()); + MultiKey multiKey = new MultiKey(c2.getTime(), e.getMaterialsProducerId(), + e.getMaterialsProducerPropertyId()); actualObservations.add(multiKey); }); @@ -4911,10 +5271,13 @@ public void testGetEventFilterForMaterialsProducerPropertyUpdateEvent() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); - MaterialsProducerId materialsProducerId = TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator); - TestMaterialsProducerPropertyId testMaterialsProducerPropertyId = TestMaterialsProducerPropertyId.getRandomMutableMaterialsProducerPropertyId(randomGenerator); + MaterialsProducerId materialsProducerId = TestMaterialsProducerId + .getRandomMaterialsProducerId(randomGenerator); + TestMaterialsProducerPropertyId testMaterialsProducerPropertyId = TestMaterialsProducerPropertyId + .getRandomMutableMaterialsProducerPropertyId(randomGenerator); Object newValue = testMaterialsProducerPropertyId.getRandomPropertyValue(randomGenerator); - materialsDataManager.setMaterialsProducerPropertyValue(materialsProducerId, testMaterialsProducerPropertyId, newValue); + materialsDataManager.setMaterialsProducerPropertyValue(materialsProducerId, + testMaterialsProducerPropertyId, newValue); MultiKey multiKey = new MultiKey(c.getTime(), materialsProducerId, testMaterialsProducerPropertyId); expectedObservations.add(multiKey); @@ -4934,7 +5297,8 @@ public void testGetEventFilterForMaterialsProducerPropertyUpdateEvent() { } @Test - @UnitTestMethod(name = "getEventFilterForMaterialsProducerResourceUpdateEvent", args = { MaterialsProducerId.class, ResourceId.class }) + @UnitTestMethod(name = "getEventFilterForMaterialsProducerResourceUpdateEvent", args = { MaterialsProducerId.class, + ResourceId.class }) public void testGetEventFilterForMaterialsProducerResourceUpdateEvent_Producer_Resource() { TestPluginData.Builder pluginBuilder = TestPluginData.builder(); @@ -4957,7 +5321,8 @@ public void testGetEventFilterForMaterialsProducerResourceUpdateEvent_Producer_R for (Pair pair : selectedPairs) { MaterialsProducerId materialsProducerId = pair.getFirst(); ResourceId resourceId = pair.getSecond(); - EventFilter eventFilter = materialsDataManager.getEventFilterForMaterialsProducerResourceUpdateEvent(materialsProducerId, resourceId); + EventFilter eventFilter = materialsDataManager + .getEventFilterForMaterialsProducerResourceUpdateEvent(materialsProducerId, resourceId); c.subscribe(eventFilter, (c2, e) -> { actualObservations.add(new MultiKey(c2.getTime(), e.getMaterialsProducerId(), e.getResourceId())); @@ -4971,7 +5336,8 @@ public void testGetEventFilterForMaterialsProducerResourceUpdateEvent_Producer_R MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); - MaterialsProducerId materialsProducerId = TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator); + MaterialsProducerId materialsProducerId = TestMaterialsProducerId + .getRandomMaterialsProducerId(randomGenerator); ResourceId resourceId = TestResourceId.getRandomResourceId(randomGenerator); StageId stageId = materialsDataManager.addStage(materialsProducerId); materialsDataManager.convertStageToResource(stageId, resourceId, 2L); @@ -4998,7 +5364,8 @@ public void testGetEventFilterForMaterialsProducerResourceUpdateEvent_Producer_R MaterialsProducerId materialsProducerId = null; ResourceId resourceId = TestResourceId.RESOURCE_1; ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.getEventFilterForMaterialsProducerResourceUpdateEvent(materialsProducerId, resourceId)); + () -> materialsDataManager + .getEventFilterForMaterialsProducerResourceUpdateEvent(materialsProducerId, resourceId)); assertEquals(MaterialsError.NULL_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); @@ -5008,7 +5375,8 @@ public void testGetEventFilterForMaterialsProducerResourceUpdateEvent_Producer_R MaterialsProducerId materialsProducerId = TestMaterialsProducerId.getUnknownMaterialsProducerId(); ResourceId resourceId = TestResourceId.RESOURCE_1; ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.getEventFilterForMaterialsProducerResourceUpdateEvent(materialsProducerId, resourceId)); + () -> materialsDataManager + .getEventFilterForMaterialsProducerResourceUpdateEvent(materialsProducerId, resourceId)); assertEquals(MaterialsError.UNKNOWN_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); @@ -5019,7 +5387,8 @@ public void testGetEventFilterForMaterialsProducerResourceUpdateEvent_Producer_R MaterialsProducerId materialsProducerId = TestMaterialsProducerId.MATERIALS_PRODUCER_1; ResourceId resourceId = null; ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.getEventFilterForMaterialsProducerResourceUpdateEvent(materialsProducerId, resourceId)); + () -> materialsDataManager + .getEventFilterForMaterialsProducerResourceUpdateEvent(materialsProducerId, resourceId)); assertEquals(ResourceError.NULL_RESOURCE_ID, contractException.getErrorType()); }); @@ -5030,7 +5399,8 @@ public void testGetEventFilterForMaterialsProducerResourceUpdateEvent_Producer_R MaterialsProducerId materialsProducerId = TestMaterialsProducerId.MATERIALS_PRODUCER_1; ResourceId resourceId = TestResourceId.getUnknownResourceId(); ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.getEventFilterForMaterialsProducerResourceUpdateEvent(materialsProducerId, resourceId)); + () -> materialsDataManager + .getEventFilterForMaterialsProducerResourceUpdateEvent(materialsProducerId, resourceId)); assertEquals(ResourceError.UNKNOWN_RESOURCE_ID, contractException.getErrorType()); }); @@ -5056,7 +5426,8 @@ public void testGetEventFilterForMaterialsProducerResourceUpdateEvent_Resource() pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); for (ResourceId resourceId : selectedResources) { - EventFilter eventFilter = materialsDataManager.getEventFilterForMaterialsProducerResourceUpdateEvent(resourceId); + EventFilter eventFilter = materialsDataManager + .getEventFilterForMaterialsProducerResourceUpdateEvent(resourceId); c.subscribe(eventFilter, (c2, e) -> { actualObservations.add(new MultiKey(c2.getTime(), e.getMaterialsProducerId(), e.getResourceId())); }); @@ -5069,7 +5440,8 @@ public void testGetEventFilterForMaterialsProducerResourceUpdateEvent_Resource() MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); - MaterialsProducerId materialsProducerId = TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator); + MaterialsProducerId materialsProducerId = TestMaterialsProducerId + .getRandomMaterialsProducerId(randomGenerator); ResourceId resourceId = TestResourceId.getRandomResourceId(randomGenerator); StageId stageId = materialsDataManager.addStage(materialsProducerId); materialsDataManager.convertStageToResource(stageId, resourceId, 2L); @@ -5093,7 +5465,8 @@ public void testGetEventFilterForMaterialsProducerResourceUpdateEvent_Resource() MaterialsActionSupport.testConsumer(7308248516735541073L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); ResourceId resourceId = null; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getEventFilterForMaterialsProducerResourceUpdateEvent(resourceId)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getEventFilterForMaterialsProducerResourceUpdateEvent(resourceId)); assertEquals(ResourceError.NULL_RESOURCE_ID, contractException.getErrorType()); }); @@ -5102,7 +5475,8 @@ public void testGetEventFilterForMaterialsProducerResourceUpdateEvent_Resource() MaterialsActionSupport.testConsumer(451212875681013142L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); ResourceId resourceId = TestResourceId.getUnknownResourceId(); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getEventFilterForMaterialsProducerResourceUpdateEvent(resourceId)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getEventFilterForMaterialsProducerResourceUpdateEvent(resourceId)); assertEquals(ResourceError.UNKNOWN_RESOURCE_ID, contractException.getErrorType()); }); @@ -5131,7 +5505,8 @@ public void testGetEventFilterForMaterialsProducerResourceUpdateEvent() { pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - EventFilter eventFilter = materialsDataManager.getEventFilterForMaterialsProducerResourceUpdateEvent(); + EventFilter eventFilter = materialsDataManager + .getEventFilterForMaterialsProducerResourceUpdateEvent(); c.subscribe(eventFilter, (c2, e) -> { actualObservations.add(new MultiKey(c2.getTime(), e.getMaterialsProducerId(), e.getResourceId())); }); @@ -5143,7 +5518,8 @@ public void testGetEventFilterForMaterialsProducerResourceUpdateEvent() { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); - MaterialsProducerId materialsProducerId = TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator); + MaterialsProducerId materialsProducerId = TestMaterialsProducerId + .getRandomMaterialsProducerId(randomGenerator); ResourceId resourceId = TestResourceId.getRandomResourceId(randomGenerator); StageId stageId = materialsDataManager.addStage(materialsProducerId); materialsDataManager.convertStageToResource(stageId, resourceId, 2L); @@ -5163,7 +5539,8 @@ public void testGetEventFilterForMaterialsProducerResourceUpdateEvent() { } @Test - @UnitTestMethod(name = "getEventFilterForStageMaterialsProducerUpdateEvent_BySource", args = { MaterialsProducerId.class }) + @UnitTestMethod(name = "getEventFilterForStageMaterialsProducerUpdateEvent_BySource", args = { + MaterialsProducerId.class }) public void testGetEventFilterForStageMaterialsProducerUpdateEvent_Source() { TestPluginData.Builder pluginBuilder = TestPluginData.builder(); @@ -5184,9 +5561,11 @@ public void testGetEventFilterForStageMaterialsProducerUpdateEvent_Source() { pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); for (MaterialsProducerId materialsProducerId : selectedProducers) { - EventFilter eventFilter = materialsDataManager.getEventFilterForStageMaterialsProducerUpdateEvent_BySource(materialsProducerId); + EventFilter eventFilter = materialsDataManager + .getEventFilterForStageMaterialsProducerUpdateEvent_BySource(materialsProducerId); c.subscribe(eventFilter, (c2, e) -> { - MultiKey multiKey = new MultiKey(c.getTime(), e.getStageId(), e.getPreviousMaterialsProducerId(), e.getCurrentMaterialsProducerId()); + MultiKey multiKey = new MultiKey(c.getTime(), e.getStageId(), e.getPreviousMaterialsProducerId(), + e.getCurrentMaterialsProducerId()); actualObservations.add(multiKey); }); } @@ -5198,7 +5577,8 @@ public void testGetEventFilterForStageMaterialsProducerUpdateEvent_Source() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - TestMaterialsProducerId sourceProducerId = TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator); + TestMaterialsProducerId sourceProducerId = TestMaterialsProducerId + .getRandomMaterialsProducerId(randomGenerator); TestMaterialsProducerId destinationProducerId; do { destinationProducerId = TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator); @@ -5228,7 +5608,8 @@ public void testGetEventFilterForStageMaterialsProducerUpdateEvent_Source() { MaterialsActionSupport.testConsumer(3035182036041809215L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); MaterialsProducerId materialsProducerId = null; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getEventFilterForStageMaterialsProducerUpdateEvent_BySource(materialsProducerId)); + ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager + .getEventFilterForStageMaterialsProducerUpdateEvent_BySource(materialsProducerId)); assertEquals(MaterialsError.NULL_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); @@ -5236,14 +5617,16 @@ public void testGetEventFilterForStageMaterialsProducerUpdateEvent_Source() { MaterialsActionSupport.testConsumer(5900407295303039835L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); MaterialsProducerId materialsProducerId = TestMaterialsProducerId.getUnknownMaterialsProducerId(); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getEventFilterForStageMaterialsProducerUpdateEvent_BySource(materialsProducerId)); + ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager + .getEventFilterForStageMaterialsProducerUpdateEvent_BySource(materialsProducerId)); assertEquals(MaterialsError.UNKNOWN_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); } @Test - @UnitTestMethod(name = "getEventFilterForStageMaterialsProducerUpdateEvent_ByDestination", args = { MaterialsProducerId.class }) + @UnitTestMethod(name = "getEventFilterForStageMaterialsProducerUpdateEvent_ByDestination", args = { + MaterialsProducerId.class }) public void testGetEventFilterForStageMaterialsProducerUpdateEvent_Destination() { TestPluginData.Builder pluginBuilder = TestPluginData.builder(); double actionTime = 0; @@ -5263,9 +5646,11 @@ public void testGetEventFilterForStageMaterialsProducerUpdateEvent_Destination() pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); for (MaterialsProducerId materialsProducerId : selectedProducers) { - EventFilter eventFilter = materialsDataManager.getEventFilterForStageMaterialsProducerUpdateEvent_ByDestination(materialsProducerId); + EventFilter eventFilter = materialsDataManager + .getEventFilterForStageMaterialsProducerUpdateEvent_ByDestination(materialsProducerId); c.subscribe(eventFilter, (c2, e) -> { - MultiKey multiKey = new MultiKey(c.getTime(), e.getStageId(), e.getPreviousMaterialsProducerId(), e.getCurrentMaterialsProducerId()); + MultiKey multiKey = new MultiKey(c.getTime(), e.getStageId(), e.getPreviousMaterialsProducerId(), + e.getCurrentMaterialsProducerId()); actualObservations.add(multiKey); }); } @@ -5277,7 +5662,8 @@ public void testGetEventFilterForStageMaterialsProducerUpdateEvent_Destination() StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - TestMaterialsProducerId sourceProducerId = TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator); + TestMaterialsProducerId sourceProducerId = TestMaterialsProducerId + .getRandomMaterialsProducerId(randomGenerator); TestMaterialsProducerId destinationProducerId; do { destinationProducerId = TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator); @@ -5308,7 +5694,8 @@ public void testGetEventFilterForStageMaterialsProducerUpdateEvent_Destination() MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); MaterialsProducerId materialsProducerId = null; ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.getEventFilterForStageMaterialsProducerUpdateEvent_ByDestination(materialsProducerId)); + () -> materialsDataManager + .getEventFilterForStageMaterialsProducerUpdateEvent_ByDestination(materialsProducerId)); assertEquals(MaterialsError.NULL_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); @@ -5317,7 +5704,8 @@ public void testGetEventFilterForStageMaterialsProducerUpdateEvent_Destination() MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); MaterialsProducerId materialsProducerId = TestMaterialsProducerId.getUnknownMaterialsProducerId(); ContractException contractException = assertThrows(ContractException.class, - () -> materialsDataManager.getEventFilterForStageMaterialsProducerUpdateEvent_ByDestination(materialsProducerId)); + () -> materialsDataManager + .getEventFilterForStageMaterialsProducerUpdateEvent_ByDestination(materialsProducerId)); assertEquals(MaterialsError.UNKNOWN_MATERIALS_PRODUCER_ID, contractException.getErrorType()); }); } @@ -5361,9 +5749,11 @@ public void testGetEventFilterForStageMaterialsProducerUpdateEvent_Stage() { pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); for (StageId stageId : selectedStages) { - EventFilter eventFilter = materialsDataManager.getEventFilterForStageMaterialsProducerUpdateEvent(stageId); + EventFilter eventFilter = materialsDataManager + .getEventFilterForStageMaterialsProducerUpdateEvent(stageId); c.subscribe(eventFilter, (c2, e) -> { - MultiKey multiKey = new MultiKey(c.getTime(), e.getStageId(), e.getPreviousMaterialsProducerId(), e.getCurrentMaterialsProducerId()); + MultiKey multiKey = new MultiKey(c.getTime(), e.getStageId(), e.getPreviousMaterialsProducerId(), + e.getCurrentMaterialsProducerId()); actualObservations.add(multiKey); }); } @@ -5383,11 +5773,13 @@ public void testGetEventFilterForStageMaterialsProducerUpdateEvent_Stage() { for (StageId stageId : stages) { if (materialsDataManager.isStageOffered(stageId)) { do { - destinationProducerId = TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator); + destinationProducerId = TestMaterialsProducerId + .getRandomMaterialsProducerId(randomGenerator); } while (sourceProducerId.equals(destinationProducerId)); materialsDataManager.transferOfferedStage(stageId, destinationProducerId); if (selectedStages.contains(stageId)) { - MultiKey multiKey = new MultiKey(c.getTime(), stageId, sourceProducerId, destinationProducerId); + MultiKey multiKey = new MultiKey(c.getTime(), stageId, sourceProducerId, + destinationProducerId); expectedObservations.add(multiKey); } } @@ -5410,7 +5802,8 @@ public void testGetEventFilterForStageMaterialsProducerUpdateEvent_Stage() { MaterialsActionSupport.testConsumer(5129361648713614556L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StageId stageId = null; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getEventFilterForStageMaterialsProducerUpdateEvent(stageId)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getEventFilterForStageMaterialsProducerUpdateEvent(stageId)); assertEquals(MaterialsError.NULL_STAGE_ID, contractException.getErrorType()); }); @@ -5418,7 +5811,8 @@ public void testGetEventFilterForStageMaterialsProducerUpdateEvent_Stage() { MaterialsActionSupport.testConsumer(99312324736600050L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StageId stageId = new StageId(100000000); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getEventFilterForStageMaterialsProducerUpdateEvent(stageId)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getEventFilterForStageMaterialsProducerUpdateEvent(stageId)); assertEquals(MaterialsError.UNKNOWN_STAGE_ID, contractException.getErrorType()); }); @@ -5440,9 +5834,11 @@ public void testGetEventFilterForStageMaterialsProducerUpdateEvent() { pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - EventFilter eventFilter = materialsDataManager.getEventFilterForStageMaterialsProducerUpdateEvent(); + EventFilter eventFilter = materialsDataManager + .getEventFilterForStageMaterialsProducerUpdateEvent(); c.subscribe(eventFilter, (c2, e) -> { - MultiKey multiKey = new MultiKey(c.getTime(), e.getStageId(), e.getPreviousMaterialsProducerId(), e.getCurrentMaterialsProducerId()); + MultiKey multiKey = new MultiKey(c.getTime(), e.getStageId(), e.getPreviousMaterialsProducerId(), + e.getCurrentMaterialsProducerId()); actualObservations.add(multiKey); }); @@ -5454,7 +5850,8 @@ public void testGetEventFilterForStageMaterialsProducerUpdateEvent() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - TestMaterialsProducerId sourceProducerId = TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator); + TestMaterialsProducerId sourceProducerId = TestMaterialsProducerId + .getRandomMaterialsProducerId(randomGenerator); TestMaterialsProducerId destinationProducerId; do { destinationProducerId = TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator); @@ -5518,7 +5915,8 @@ public void testGetEventFilterForStageOfferUpdateEvent_Stage() { pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); for (StageId stageId : selectedStages) { - EventFilter eventFilter = materialsDataManager.getEventFilterForStageOfferUpdateEvent(stageId); + EventFilter eventFilter = materialsDataManager + .getEventFilterForStageOfferUpdateEvent(stageId); c.subscribe(eventFilter, (c2, e) -> { actualObservations.add(new MultiKey(c2.getTime(), e.getStageId())); }); @@ -5560,7 +5958,8 @@ public void testGetEventFilterForStageOfferUpdateEvent_Stage() { MaterialsActionSupport.testConsumer(4844028463801822799L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StageId stageId = null; - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getEventFilterForStageOfferUpdateEvent(stageId)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getEventFilterForStageOfferUpdateEvent(stageId)); assertEquals(MaterialsError.NULL_STAGE_ID, contractException.getErrorType()); }); @@ -5568,7 +5967,8 @@ public void testGetEventFilterForStageOfferUpdateEvent_Stage() { MaterialsActionSupport.testConsumer(7970389114090461374L, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); StageId stageId = new StageId(10000000); - ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager.getEventFilterForStageOfferUpdateEvent(stageId)); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.getEventFilterForStageOfferUpdateEvent(stageId)); assertEquals(MaterialsError.UNKNOWN_STAGE_ID, contractException.getErrorType()); }); @@ -5605,7 +6005,8 @@ public void testGetEventFilterForStageOfferUpdateEvent() { // have a agent observe stage creations pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - EventFilter eventFilter = materialsDataManager.getEventFilterForStageOfferUpdateEvent(); + EventFilter eventFilter = materialsDataManager + .getEventFilterForStageOfferUpdateEvent(); c.subscribe(eventFilter, (c2, e) -> { actualObservations.add(new MultiKey(c2.getTime(), e.getStageId())); }); @@ -5673,16 +6074,18 @@ public void testGetEventFilterForBatchAdditionEvent() { RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - MaterialsProducerId materialsProducerId = TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator); + MaterialsProducerId materialsProducerId = TestMaterialsProducerId + .getRandomMaterialsProducerId(randomGenerator); TestMaterialId testMaterialId = TestMaterialId.getRandomMaterialId(randomGenerator); double amount = randomGenerator.nextDouble(); BatchConstructionInfo.Builder batchBuilder = BatchConstructionInfo.builder(); // batchBuilder.setMaterialsProducerId(materialsProducerId)// - .setMaterialId(testMaterialId)// - .setAmount(amount);// + .setMaterialId(testMaterialId)// + .setAmount(amount);// - for (TestBatchPropertyId testBatchPropertyId : TestBatchPropertyId.getTestBatchPropertyIds(testMaterialId)) { + for (TestBatchPropertyId testBatchPropertyId : TestBatchPropertyId + .getTestBatchPropertyIds(testMaterialId)) { Object propertyValue = testBatchPropertyId.getRandomPropertyValue(randomGenerator); batchBuilder.setPropertyValue(testBatchPropertyId, propertyValue); } @@ -5719,7 +6122,8 @@ public void testGetEventFilterForBatchAmountUpdateEvent() { // have a agent observe batch amount updates pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - EventFilter eventFilter = materialsDataManager.getEventFilterForBatchAmountUpdateEvent(); + EventFilter eventFilter = materialsDataManager + .getEventFilterForBatchAmountUpdateEvent(); c.subscribe(eventFilter, (c2, e) -> { actualObservations.add(new MultiKey(c2.getTime(), e.getBatchId())); }); @@ -5733,16 +6137,18 @@ public void testGetEventFilterForBatchAmountUpdateEvent() { RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - MaterialsProducerId materialsProducerId = TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator); + MaterialsProducerId materialsProducerId = TestMaterialsProducerId + .getRandomMaterialsProducerId(randomGenerator); TestMaterialId testMaterialId = TestMaterialId.getRandomMaterialId(randomGenerator); double amount = randomGenerator.nextDouble() + 0.01; BatchConstructionInfo.Builder batchBuilder = BatchConstructionInfo.builder(); batchBuilder.setMaterialsProducerId(materialsProducerId)// - .setMaterialId(testMaterialId)// - .setAmount(amount);// + .setMaterialId(testMaterialId)// + .setAmount(amount);// - for (TestBatchPropertyId testBatchPropertyId : TestBatchPropertyId.getTestBatchPropertyIds(testMaterialId)) { + for (TestBatchPropertyId testBatchPropertyId : TestBatchPropertyId + .getTestBatchPropertyIds(testMaterialId)) { Object propertyValue = testBatchPropertyId.getRandomPropertyValue(randomGenerator); batchBuilder.setPropertyValue(testBatchPropertyId, propertyValue); } @@ -5751,10 +6157,11 @@ public void testGetEventFilterForBatchAmountUpdateEvent() { BatchId batchId1 = materialsDataManager.addBatch(batchConstructionInfo); batchBuilder.setMaterialsProducerId(materialsProducerId)// - .setMaterialId(testMaterialId)// - .setAmount(amount);// + .setMaterialId(testMaterialId)// + .setAmount(amount);// - for (TestBatchPropertyId testBatchPropertyId : TestBatchPropertyId.getTestBatchPropertyIds(testMaterialId)) { + for (TestBatchPropertyId testBatchPropertyId : TestBatchPropertyId + .getTestBatchPropertyIds(testMaterialId)) { Object propertyValue = testBatchPropertyId.getRandomPropertyValue(randomGenerator); batchBuilder.setPropertyValue(testBatchPropertyId, propertyValue); } @@ -5794,7 +6201,8 @@ public void testGetEventFilterForBatchImminentRemovalEvent() { // have a agent observe batch removals pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - EventFilter eventFilter = materialsDataManager.getEventFilterForBatchImminentRemovalEvent(); + EventFilter eventFilter = materialsDataManager + .getEventFilterForBatchImminentRemovalEvent(); c.subscribe(eventFilter, (c2, e) -> { actualObservations.add(new MultiKey(c2.getTime(), e.getBatchId())); }); @@ -5808,16 +6216,18 @@ public void testGetEventFilterForBatchImminentRemovalEvent() { RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - MaterialsProducerId materialsProducerId = TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator); + MaterialsProducerId materialsProducerId = TestMaterialsProducerId + .getRandomMaterialsProducerId(randomGenerator); TestMaterialId testMaterialId = TestMaterialId.getRandomMaterialId(randomGenerator); double amount = randomGenerator.nextDouble() + 0.01; BatchConstructionInfo.Builder batchBuilder = BatchConstructionInfo.builder(); batchBuilder.setMaterialsProducerId(materialsProducerId)// - .setMaterialId(testMaterialId)// - .setAmount(amount);// + .setMaterialId(testMaterialId)// + .setAmount(amount);// - for (TestBatchPropertyId testBatchPropertyId : TestBatchPropertyId.getTestBatchPropertyIds(testMaterialId)) { + for (TestBatchPropertyId testBatchPropertyId : TestBatchPropertyId + .getTestBatchPropertyIds(testMaterialId)) { Object propertyValue = testBatchPropertyId.getRandomPropertyValue(randomGenerator); batchBuilder.setPropertyValue(testBatchPropertyId, propertyValue); } @@ -5855,7 +6265,8 @@ public void testGetEventFilterForBatchPropertyDefinitionEvent() { // have a agent observe batch property definition constructions pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - EventFilter eventFilter = materialsDataManager.getEventFilterForBatchPropertyDefinitionEvent(); + EventFilter eventFilter = materialsDataManager + .getEventFilterForBatchPropertyDefinitionEvent(); c.subscribe(eventFilter, (c2, e) -> { actualObservations.add(new MultiKey(c2.getTime(), e.getBatchPropertyId())); }); @@ -5871,16 +6282,16 @@ public void testGetEventFilterForBatchPropertyDefinitionEvent() { TestMaterialId testMaterialId = TestMaterialId.getRandomMaterialId(randomGenerator); int defaultValue = randomGenerator.nextInt(100); - PropertyDefinition propertyDefinition = PropertyDefinition .builder()// - .setType(Integer.class)// - .setDefaultValue(defaultValue)// - .build(); + PropertyDefinition propertyDefinition = PropertyDefinition.builder()// + .setType(Integer.class)// + .setDefaultValue(defaultValue)// + .build(); BatchPropertyId batchPropertyId = TestBatchPropertyId.getUnknownBatchPropertyId(); BatchPropertyDefinitionInitialization batchPropertyDefinitionInitialization = // - BatchPropertyDefinitionInitialization .builder()// - .setMaterialId(testMaterialId).setPropertyDefinition(propertyDefinition)// - .setPropertyId(batchPropertyId)// - .build();// + BatchPropertyDefinitionInitialization.builder()// + .setMaterialId(testMaterialId).setPropertyDefinition(propertyDefinition)// + .setPropertyId(batchPropertyId)// + .build();// materialsDataManager.defineBatchProperty(batchPropertyDefinitionInitialization); expectedObservations.add(new MultiKey(c.getTime(), batchPropertyId)); @@ -5912,7 +6323,8 @@ public void testGetEventFilterForBatchPropertyUpdateEvent() { // have a agent observe batch property property updates pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - EventFilter eventFilter = materialsDataManager.getEventFilterForBatchPropertyUpdateEvent(); + EventFilter eventFilter = materialsDataManager + .getEventFilterForBatchPropertyUpdateEvent(); c.subscribe(eventFilter, (c2, e) -> { actualObservations.add(new MultiKey(c2.getTime(), e.getBatchId(), e.getBatchPropertyId())); }); @@ -5926,16 +6338,18 @@ public void testGetEventFilterForBatchPropertyUpdateEvent() { RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - MaterialsProducerId materialsProducerId = TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator); + MaterialsProducerId materialsProducerId = TestMaterialsProducerId + .getRandomMaterialsProducerId(randomGenerator); TestMaterialId testMaterialId = TestMaterialId.getRandomMaterialId(randomGenerator); double amount = randomGenerator.nextDouble() + 0.01; BatchConstructionInfo.Builder batchBuilder = BatchConstructionInfo.builder(); batchBuilder.setMaterialsProducerId(materialsProducerId)// - .setMaterialId(testMaterialId)// - .setAmount(amount);// + .setMaterialId(testMaterialId)// + .setAmount(amount);// - for (TestBatchPropertyId testBatchPropertyId : TestBatchPropertyId.getTestBatchPropertyIds(testMaterialId)) { + for (TestBatchPropertyId testBatchPropertyId : TestBatchPropertyId + .getTestBatchPropertyIds(testMaterialId)) { Object propertyValue = testBatchPropertyId.getRandomPropertyValue(randomGenerator); batchBuilder.setPropertyValue(testBatchPropertyId, propertyValue); } @@ -5943,7 +6357,8 @@ public void testGetEventFilterForBatchPropertyUpdateEvent() { BatchConstructionInfo batchConstructionInfo = batchBuilder.build(); BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); - TestBatchPropertyId batchPropertyId = TestBatchPropertyId.getRandomMutableBatchPropertyId(testMaterialId, randomGenerator); + TestBatchPropertyId batchPropertyId = TestBatchPropertyId + .getRandomMutableBatchPropertyId(testMaterialId, randomGenerator); Object propertyValue = batchPropertyId.getRandomPropertyValue(randomGenerator); materialsDataManager.setBatchPropertyValue(batchId, batchPropertyId, propertyValue); @@ -5975,7 +6390,8 @@ public void testGetEventFilterForMaterialIdAdditionEvent() { // have a agent observe the addition of material types pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - EventFilter eventFilter = materialsDataManager.getEventFilterForMaterialIdAdditionEvent(); + EventFilter eventFilter = materialsDataManager + .getEventFilterForMaterialIdAdditionEvent(); c.subscribe(eventFilter, (c2, e) -> { actualObservations.add(new MultiKey(c2.getTime(), e.getMaterialId())); }); @@ -6016,7 +6432,8 @@ public void testGetEventFilterForMaterialsProducerAdditionEvent() { // have an agent observe the addition of material producers pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - EventFilter eventFilter = materialsDataManager.getEventFilterForMaterialsProducerAdditionEvent(); + EventFilter eventFilter = materialsDataManager + .getEventFilterForMaterialsProducerAdditionEvent(); c.subscribe(eventFilter, (c2, e) -> { actualObservations.add(new MultiKey(c2.getTime(), e.getMaterialsProducerId())); }); @@ -6035,7 +6452,8 @@ public void testGetEventFilterForMaterialsProducerAdditionEvent() { builder.setMaterialsProducerId(materialsProducerId);// - for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId.values()) { + for (TestMaterialsProducerPropertyId testMaterialsProducerPropertyId : TestMaterialsProducerPropertyId + .values()) { Object propertyValue = testMaterialsProducerPropertyId.getRandomPropertyValue(randomGenerator); builder.setMaterialsProducerPropertyValue(testMaterialsProducerPropertyId, propertyValue); } @@ -6071,9 +6489,10 @@ public void testGetEventFilterForMaterialsProducerPropertyDefinitionEvent() { // have an agent observe the definition of material producer properties pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - EventFilter eventFilter = materialsDataManager.getEventFilterForMaterialsProducerPropertyDefinitionEvent(); + EventFilter eventFilter = materialsDataManager + .getEventFilterForMaterialsProducerPropertyDefinitionEvent(); c.subscribe(eventFilter, (c2, e) -> { - actualObservations.add(new MultiKey(c2.getTime(), e.getPersonPropertyId())); + actualObservations.add(new MultiKey(c2.getTime(), e.getProducerPropertyId())); }); })); @@ -6083,21 +6502,22 @@ public void testGetEventFilterForMaterialsProducerPropertyDefinitionEvent() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - - MaterialsProducerPropertyId materialsProducerPropertyId = TestMaterialsProducerPropertyId.getUnknownMaterialsProducerPropertyId(); + + MaterialsProducerPropertyId materialsProducerPropertyId = TestMaterialsProducerPropertyId + .getUnknownMaterialsProducerPropertyId(); int defaultValue = randomGenerator.nextInt(100); PropertyDefinition propertyDefinition = PropertyDefinition.builder()// - .setType(Integer.class)// - .setDefaultValue(defaultValue)// - .build(); - - MaterialsProducerPropertyDefinitionInitialization materialsProducerPropertyDefinitionInitialization = MaterialsProducerPropertyDefinitionInitialization.builder()// - .setMaterialsProducerPropertyId(materialsProducerPropertyId)// - .setPropertyDefinition(propertyDefinition)// - .build(); + .setType(Integer.class)// + .setDefaultValue(defaultValue)// + .build(); + + MaterialsProducerPropertyDefinitionInitialization materialsProducerPropertyDefinitionInitialization = MaterialsProducerPropertyDefinitionInitialization + .builder()// + .setMaterialsProducerPropertyId(materialsProducerPropertyId)// + .setPropertyDefinition(propertyDefinition)// + .build(); materialsDataManager.defineMaterialsProducerProperty(materialsProducerPropertyDefinitionInitialization); - expectedObservations.add(new MultiKey(c.getTime(), materialsProducerPropertyId)); })); } @@ -6139,10 +6559,11 @@ public void testGetEventFilterForStageAdditionEvent() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - - TestMaterialsProducerId materialsProducerId = TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator); + + TestMaterialsProducerId materialsProducerId = TestMaterialsProducerId + .getRandomMaterialsProducerId(randomGenerator); StageId stageId = materialsDataManager.addStage(materialsProducerId); - + expectedObservations.add(new MultiKey(c.getTime(), stageId)); })); } @@ -6172,7 +6593,8 @@ public void testGetEventFilterForStageImminentRemovalEvent() { // have an agent observe the imminent removal of stages pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - EventFilter eventFilter = materialsDataManager.getEventFilterForStageImminentRemovalEvent(); + EventFilter eventFilter = materialsDataManager + .getEventFilterForStageImminentRemovalEvent(); c.subscribe(eventFilter, (c2, e) -> { actualObservations.add(new MultiKey(c2.getTime(), e.getStageId())); }); @@ -6184,13 +6606,14 @@ public void testGetEventFilterForStageImminentRemovalEvent() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - - TestMaterialsProducerId materialsProducerId = TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator); + + TestMaterialsProducerId materialsProducerId = TestMaterialsProducerId + .getRandomMaterialsProducerId(randomGenerator); StageId stageId = materialsDataManager.addStage(materialsProducerId); materialsDataManager.removeStage(stageId, false); - + expectedObservations.add(new MultiKey(c.getTime(), stageId)); - + })); } @@ -6203,7 +6626,7 @@ public void testGetEventFilterForStageImminentRemovalEvent() { TestPluginData testPluginData = pluginBuilder.build(); Plugin testPlugin = TestPlugin.getTestPlugin(testPluginData); MaterialsActionSupport.testConsumers(4965736606382697699L, testPlugin); - + } @Test @@ -6219,7 +6642,8 @@ public void testGetEventFilterForStageMembershipAdditionEvent() { // have an agent observe the imminent removal of stages pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - EventFilter eventFilter = materialsDataManager.getEventFilterForStageImminentRemovalEvent(); + EventFilter eventFilter = materialsDataManager + .getEventFilterForStageImminentRemovalEvent(); c.subscribe(eventFilter, (c2, e) -> { actualObservations.add(new MultiKey(c2.getTime(), e.getStageId())); }); @@ -6231,13 +6655,14 @@ public void testGetEventFilterForStageMembershipAdditionEvent() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - - TestMaterialsProducerId materialsProducerId = TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator); + + TestMaterialsProducerId materialsProducerId = TestMaterialsProducerId + .getRandomMaterialsProducerId(randomGenerator); StageId stageId = materialsDataManager.addStage(materialsProducerId); materialsDataManager.removeStage(stageId, false); - + expectedObservations.add(new MultiKey(c.getTime(), stageId)); - + })); } @@ -6251,7 +6676,6 @@ public void testGetEventFilterForStageMembershipAdditionEvent() { Plugin testPlugin = TestPlugin.getTestPlugin(testPluginData); MaterialsActionSupport.testConsumers(3581801183499812974L, testPlugin); - } @Test @@ -6267,7 +6691,8 @@ public void testGetEventFilterForStageMembershipRemovalEvent() { // have an agent observe the removal of batches from stages pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - EventFilter eventFilter = materialsDataManager.getEventFilterForStageMembershipRemovalEvent(); + EventFilter eventFilter = materialsDataManager + .getEventFilterForStageMembershipRemovalEvent(); c.subscribe(eventFilter, (c2, e) -> { actualObservations.add(new MultiKey(c2.getTime(), e.getStageId(), e.getBatchId())); }); @@ -6279,8 +6704,9 @@ public void testGetEventFilterForStageMembershipRemovalEvent() { StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); - - TestMaterialsProducerId materialsProducerId = TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator); + + TestMaterialsProducerId materialsProducerId = TestMaterialsProducerId + .getRandomMaterialsProducerId(randomGenerator); double amount = randomGenerator.nextDouble(); StageId stageId = materialsDataManager.addStage(materialsProducerId); TestMaterialId materialId = TestMaterialId.getRandomMaterialId(randomGenerator); @@ -6288,7 +6714,8 @@ public void testGetEventFilterForStageMembershipRemovalEvent() { batchBuilder.setMaterialsProducerId(materialsProducerId); batchBuilder.setAmount(amount); batchBuilder.setMaterialId(materialId); - for(TestBatchPropertyId testBatchPropertyId : TestBatchPropertyId.getTestBatchPropertyIds(materialId)) { + for (TestBatchPropertyId testBatchPropertyId : TestBatchPropertyId + .getTestBatchPropertyIds(materialId)) { Object propertyValue = testBatchPropertyId.getRandomPropertyValue(randomGenerator); batchBuilder.setPropertyValue(testBatchPropertyId, propertyValue); } @@ -6296,9 +6723,9 @@ public void testGetEventFilterForStageMembershipRemovalEvent() { BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); materialsDataManager.moveBatchToStage(batchId, stageId); materialsDataManager.moveBatchToInventory(batchId); - - expectedObservations.add(new MultiKey(c.getTime(), stageId,batchId)); - + + expectedObservations.add(new MultiKey(c.getTime(), stageId, batchId)); + })); } @@ -6314,4 +6741,283 @@ public void testGetEventFilterForStageMembershipRemovalEvent() { } + @Test + @UnitTestMethod(name = "defineMaterialsProducerProperty", args = { + MaterialsProducerPropertyDefinitionInitialization.class }) + public void testDefineMaterialsProducerProperty() { + TestPluginData.Builder pluginBuilder = TestPluginData.builder(); + double actionTime = 0; + + Set expectedObservations = new LinkedHashSet<>(); + Set actualObservations = new LinkedHashSet<>(); + + pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { + c.subscribe(EventFilter.builder(MaterialsProducerPropertyDefinitionEvent.class).build(), (c2, e) -> { + actualObservations.add(new MultiKey(c2.getTime(), e.getProducerPropertyId())); + }); + })); + + for (int i = 0; i < 15; i++) { + MaterialsProducerPropertyId producerId = TestMaterialsProducerPropertyId + .getUnknownMaterialsProducerPropertyId(); + PropertyDefinition propertyDefinition = PropertyDefinition.builder() + .setDefaultValue(100 * i) + .setPropertyValueMutability(false) + .setTimeTrackingPolicy(TimeTrackingPolicy.TRACK_TIME) + .setType(Integer.class) + .build(); + MaterialsProducerPropertyDefinitionInitialization matprodpropdefinit = MaterialsProducerPropertyDefinitionInitialization + .builder() + .setMaterialsProducerPropertyId(producerId) + .setPropertyDefinition(propertyDefinition) + .build(); + + pluginBuilder.addTestActorPlan("actor", new TestActorPlan(actionTime++, (c) -> { + MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); + materialsDataManager.defineMaterialsProducerProperty(matprodpropdefinit); + expectedObservations.add(new MultiKey(c.getTime(), producerId)); + })); + } + // have the observer show that the correct observations were generated + pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { + assertTrue(expectedObservations.size() > 0); + assertEquals(expectedObservations, actualObservations); + })); + + // precondition: Materials producer property definition init is null + MaterialsActionSupport.testConsumer(3735323519290927676L, (c) -> { + MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); + ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager + .defineMaterialsProducerProperty(null)); + assertEquals(MaterialsError.NULL_MATERIALS_PRODUCER_PROPERTY_DEFINITION_INITIALIZATION, + contractException.getErrorType()); + + }); + + // precondition: duplicate Materials producer property id + MaterialsActionSupport.testConsumer(3735323519290927676L, (c) -> { + MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); + ContractException contractException = assertThrows(ContractException.class, () -> { + TestMaterialsProducerPropertyId producerId = TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_3_DOUBLE_MUTABLE_NO_TRACK; + MaterialsProducerPropertyDefinitionInitialization matprodpropdefinit = MaterialsProducerPropertyDefinitionInitialization + .builder() + .setMaterialsProducerPropertyId(producerId) + .setPropertyDefinition(producerId.getPropertyDefinition()) + .build(); + + materialsDataManager.defineMaterialsProducerProperty(matprodpropdefinit); + }); + assertEquals(MaterialsError.DUPLICATE_MATERIALS_PRODUCER_PROPERTY_ID, contractException.getErrorType()); + + }); + + // precondition: insufficient property value assignment + MaterialsActionSupport.testConsumer(6282192460518073310L, (c) -> { + MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); + ContractException contractException = assertThrows(ContractException.class, () -> { + MaterialsProducerPropertyId materialsProducerPropertyId = TestMaterialsProducerPropertyId + .getUnknownMaterialsProducerPropertyId(); + PropertyDefinition propertyDefinition = PropertyDefinition.builder().setPropertyValueMutability(false) + .setTimeTrackingPolicy(TimeTrackingPolicy.TRACK_TIME).setType(Integer.class).build(); + MaterialsProducerPropertyDefinitionInitialization matprodpropdefinit = MaterialsProducerPropertyDefinitionInitialization + .builder() + .setMaterialsProducerPropertyId(materialsProducerPropertyId) + .setPropertyDefinition(propertyDefinition) + .build(); + + materialsDataManager.defineMaterialsProducerProperty(matprodpropdefinit); + }); + assertEquals(PropertyError.INSUFFICIENT_PROPERTY_VALUE_ASSIGNMENT, contractException.getErrorType()); + + }); + + TestPluginData testPluginData = pluginBuilder.build(); + Plugin testPlugin = TestPlugin.getTestPlugin(testPluginData); + MaterialsActionSupport.testConsumers(2721085458686966421L, testPlugin); + } + + @Test + @UnitTestMethod(name = "convertStageToResource", args = { StageId.class, ResourceId.class, long.class }) + public void testConvertStageToResource() { + TestPluginData.Builder pluginBuilder = TestPluginData.builder(); + double actionTime = 0; + + // create containers to hold observations + Set expectedObservations = new LinkedHashSet<>(); + Set actualObservations = new LinkedHashSet<>(); + + // have an actor observe + pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { + + c.subscribe(EventFilter.builder(BatchImminentRemovalEvent.class).build(), (c2, e) -> { + actualObservations.add(new MultiKey(c2.getTime(), e.getBatchId(), "removal")); + }); + + c.subscribe(EventFilter.builder(MaterialsProducerResourceUpdateEvent.class).build(), (c2, e) -> { + actualObservations + .add(new MultiKey(c2.getTime(), e.getResourceId(), e.getCurrentResourceLevel(), "update")); + }); + + c.subscribe(EventFilter.builder(StageImminentRemovalEvent.class).build(), (c2, e) -> { + actualObservations.add(new MultiKey(c2.getTime(), e.getStageId())); + }); + + })); + + // have the producers generate batches via stage conversion + for (TestMaterialsProducerId testMaterialsProducerId : TestMaterialsProducerId.values()) { + + List stagesToConfirm = new ArrayList<>(); + List batchesToConfirm = new ArrayList<>(); + pluginBuilder.addTestActorPlan("actor", new TestActorPlan(actionTime++, (c) -> { + MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); + ResourcesDataManager resourcesDataManager = c.getDataManager(ResourcesDataManager.class); + StochasticsDataManager stochasticsDataManager = c.getDataManager(StochasticsDataManager.class); + RandomGenerator randomGenerator = stochasticsDataManager.getRandomGenerator(); + for (int i = 0; i < 50; i++) { + StageId stageId = materialsDataManager.addStage(testMaterialsProducerId); + + MaterialId materialId; + ResourceId resourceId; + double amount; + long resourceAmount; + int batchCount = randomGenerator.nextInt(3); + for (int j = 0; j < batchCount; j++) { + materialId = TestMaterialId.getRandomMaterialId(randomGenerator); + amount = randomGenerator.nextDouble() + 0.01; + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo + .getBatchConstructionInfo(testMaterialsProducerId, materialId, amount, randomGenerator); + BatchId batchId = materialsDataManager.addBatch(batchConstructionInfo); + materialsDataManager.moveBatchToStage(batchId, stageId); + } + resourceId = TestResourceId.getRandomResourceId(randomGenerator); + resourceAmount = 125L; + + long previousResourceAmount = materialsDataManager + .getMaterialsProducerResourceLevel(testMaterialsProducerId, resourceId); + long newResourceAmount = resourceAmount + previousResourceAmount; + + List stageBatches = materialsDataManager.getStageBatches(stageId); + materialsDataManager.convertStageToResource(stageId, resourceId, resourceAmount); + + // record the stages and batches that should be removed, but + // only after the current actor activation + stagesToConfirm.add(stageId); + batchesToConfirm.addAll(stageBatches); + + // show that the stage was properly converted + assertTrue(resourcesDataManager.resourceIdExists(resourceId)); + assertEquals(newResourceAmount, materialsDataManager + .getMaterialsProducerResourceLevel(testMaterialsProducerId, resourceId)); + + // generate the expected observations + for (BatchId batchId : stageBatches) { + expectedObservations.add(new MultiKey(c.getTime(), batchId, "removal")); + } + expectedObservations.add(new MultiKey(c.getTime(), resourceId, newResourceAmount, "update")); + expectedObservations.add(new MultiKey(c.getTime(), stageId)); + } + })); + + // show that the stages and batches used to generate the new batches + // were in fact removed + pluginBuilder.addTestActorPlan("actor", new TestActorPlan(actionTime++, (c) -> { + MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); + for (StageId stageId : stagesToConfirm) { + assertFalse(materialsDataManager.stageExists(stageId)); + } + for (BatchId batchId : batchesToConfirm) { + assertFalse(materialsDataManager.batchExists(batchId)); + } + })); + } + + // have the observer show that the correct observations were generated + pluginBuilder.addTestActorPlan("observer", new TestActorPlan(actionTime++, (c) -> { + assertTrue(expectedObservations.size() > 0); + assertEquals(expectedObservations, actualObservations); + })); + + /* precondition test: if the resource id is null */ + MaterialsActionSupport.testConsumer(2645688892533853761L, (c) -> { + MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); + StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); + long amount = 125L; + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.convertStageToResource(stageId, null, amount)); + assertEquals(ResourceError.NULL_RESOURCE_ID, contractException.getErrorType()); + }); + + /* precondition test: if the resource id is unknown */ + MaterialsActionSupport.testConsumer(5663564750797913460L, (c) -> { + MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); + StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); + long amount = 125L; + ContractException contractException = assertThrows(ContractException.class, () -> materialsDataManager + .convertStageToResource(stageId, TestResourceId.getUnknownResourceId(), amount)); + assertEquals(ResourceError.UNKNOWN_RESOURCE_ID, contractException.getErrorType()); + + }); + + /* precondition test: if the stage id is null */ + MaterialsActionSupport.testConsumer(4802037379297224622L, (c) -> { + MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); + ResourceId resourceId = TestResourceId.RESOURCE_1; + long amount = 125L; + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.convertStageToResource(null, resourceId, amount)); + assertEquals(MaterialsError.NULL_STAGE_ID, contractException.getErrorType()); + + }); + + /* precondition test: if stage id is unknown */ + MaterialsActionSupport.testConsumer(2648372629715030136L, (c) -> { + MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); + ResourceId resourceId = TestResourceId.RESOURCE_1; + long amount = 125L; + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.convertStageToResource(new StageId(10000000), resourceId, amount)); + assertEquals(MaterialsError.UNKNOWN_STAGE_ID, contractException.getErrorType()); + }); + + /* precondition test: if the stage is offered */ + MaterialsActionSupport.testConsumer(4249451090321590319L, (c) -> { + MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); + StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); + ResourceId resourceId = TestResourceId.RESOURCE_1; + long amount = 125L; + materialsDataManager.setStageOfferState(stageId, true); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.convertStageToResource(stageId, resourceId, amount)); + assertEquals(MaterialsError.OFFERED_STAGE_UNALTERABLE, contractException.getErrorType()); + }); + + /* precondition test: if the material amount is negative */ + MaterialsActionSupport.testConsumer(6695497074307172608L, (c) -> { + MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); + StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); + ResourceId resourceId = TestResourceId.RESOURCE_1; + + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.convertStageToResource(stageId, resourceId, -1L)); + assertEquals(ResourceError.NEGATIVE_RESOURCE_AMOUNT, contractException.getErrorType()); + }); + + /* precondition test: if the resource amount is not finite */ + MaterialsActionSupport.testConsumer(4334935928753037959L, (c) -> { + MaterialsDataManager materialsDataManager = c.getDataManager(MaterialsDataManager.class); + StageId stageId = materialsDataManager.addStage(TestMaterialsProducerId.MATERIALS_PRODUCER_1); + ResourceId resourceId = TestResourceId.RESOURCE_1; + + materialsDataManager.convertStageToResource(stageId, resourceId, 10L); + ContractException contractException = assertThrows(ContractException.class, + () -> materialsDataManager.convertStageToResource(stageId, resourceId, Long.MAX_VALUE)); + assertEquals(ResourceError.RESOURCE_ARITHMETIC_EXCEPTION, contractException.getErrorType()); + }); + + TestPluginData testPluginData = pluginBuilder.build(); + Plugin testPlugin = TestPlugin.getTestPlugin(testPluginData); + MaterialsActionSupport.testConsumers(7822140774565669544L, testPlugin); + } + } diff --git a/gcm4/src/test/java/plugins/materials/events/AT_BatchPropertyDefinitionEvent.java b/gcm4/src/test/java/plugins/materials/events/AT_BatchPropertyDefinitionEvent.java new file mode 100644 index 000000000..6c68a2cbb --- /dev/null +++ b/gcm4/src/test/java/plugins/materials/events/AT_BatchPropertyDefinitionEvent.java @@ -0,0 +1,68 @@ +package plugins.materials.events; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.junit.jupiter.api.Test; + +import plugins.materials.support.BatchPropertyId; +import plugins.materials.support.MaterialId; +import plugins.materials.support.MaterialsError; +import plugins.materials.testsupport.TestBatchPropertyId; +import plugins.materials.testsupport.TestMaterialId; +import plugins.util.properties.PropertyError; +import tools.annotations.UnitTest; +import tools.annotations.UnitTestConstructor; +import tools.annotations.UnitTestMethod; +import util.errors.ContractException; + +@UnitTest(target = BatchPropertyDefinitionEvent.class) +public class AT_BatchPropertyDefinitionEvent { + @Test + @UnitTestConstructor(args = { MaterialId.class, BatchPropertyId.class }) + public void testConstructor() { + MaterialId materialId = TestMaterialId.MATERIAL_1; + BatchPropertyId batchPropertyId = TestBatchPropertyId.BATCH_PROPERTY_1_2_INTEGER_MUTABLE_NO_TRACK; + + BatchPropertyDefinitionEvent event = new BatchPropertyDefinitionEvent(materialId, batchPropertyId); + + assertNotNull(event); + + // precondition: null material id + ContractException contractException = assertThrows(ContractException.class, + () -> new BatchPropertyDefinitionEvent(null, batchPropertyId)); + assertEquals(MaterialsError.NULL_MATERIAL_ID, contractException.getErrorType()); + + // precondition: null property id + contractException = assertThrows(ContractException.class, + () -> new BatchPropertyDefinitionEvent(materialId, null)); + assertEquals(PropertyError.NULL_PROPERTY_ID, contractException.getErrorType()); + } + + @Test + @UnitTestMethod(name = "getBatchPropertyId", args = {}) + public void testGetBatchPropertyId() { + MaterialId materialId = TestMaterialId.MATERIAL_1; + BatchPropertyId batchPropertyId = TestBatchPropertyId.BATCH_PROPERTY_1_2_INTEGER_MUTABLE_NO_TRACK; + + BatchPropertyDefinitionEvent event = new BatchPropertyDefinitionEvent(materialId, batchPropertyId); + + assertNotNull(event); + + assertEquals(batchPropertyId, event.getBatchPropertyId()); + } + + @Test + @UnitTestMethod(name = "getMaterialId", args = {}) + public void testGetMaterialId() { + MaterialId materialId = TestMaterialId.MATERIAL_1; + BatchPropertyId batchPropertyId = TestBatchPropertyId.BATCH_PROPERTY_1_2_INTEGER_MUTABLE_NO_TRACK; + + BatchPropertyDefinitionEvent event = new BatchPropertyDefinitionEvent(materialId, batchPropertyId); + + assertNotNull(event); + + assertEquals(materialId, event.getMaterialId()); + } +} diff --git a/gcm4/src/test/java/plugins/materials/events/AT_BatchPropertyUpdateEvent.java b/gcm4/src/test/java/plugins/materials/events/AT_BatchPropertyUpdateEvent.java index 130a5b7b5..71394f5fd 100644 --- a/gcm4/src/test/java/plugins/materials/events/AT_BatchPropertyUpdateEvent.java +++ b/gcm4/src/test/java/plugins/materials/events/AT_BatchPropertyUpdateEvent.java @@ -4,7 +4,6 @@ import org.junit.jupiter.api.Test; -import nucleus.Event; import plugins.materials.support.BatchId; import plugins.materials.support.BatchPropertyId; import plugins.materials.testsupport.TestBatchPropertyId; @@ -13,7 +12,7 @@ import tools.annotations.UnitTestMethod; @UnitTest(target = BatchPropertyUpdateEvent.class) -public class AT_BatchPropertyUpdateEvent implements Event { +public class AT_BatchPropertyUpdateEvent { @Test @UnitTestConstructor(args = { BatchId.class, BatchPropertyId.class, Object.class, Object.class }) diff --git a/gcm4/src/test/java/plugins/materials/events/AT_MaterialIdAdditionEvent.java b/gcm4/src/test/java/plugins/materials/events/AT_MaterialIdAdditionEvent.java new file mode 100644 index 000000000..afd2b9e7d --- /dev/null +++ b/gcm4/src/test/java/plugins/materials/events/AT_MaterialIdAdditionEvent.java @@ -0,0 +1,43 @@ +package plugins.materials.events; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.junit.jupiter.api.Test; + +import plugins.materials.support.MaterialId; +import plugins.materials.support.MaterialsError; +import plugins.materials.testsupport.TestMaterialId; +import tools.annotations.UnitTest; +import tools.annotations.UnitTestConstructor; +import tools.annotations.UnitTestMethod; +import util.errors.ContractException; + +@UnitTest(target = MaterialIdAdditionEvent.class) +public class AT_MaterialIdAdditionEvent { + + @Test + @UnitTestConstructor(args = { MaterialId.class }) + public void testConstructor() { + MaterialId materialId = TestMaterialId.MATERIAL_1; + MaterialIdAdditionEvent event = new MaterialIdAdditionEvent(materialId); + + assertNotNull(event); + + // precondition: null material id + ContractException contractException = assertThrows(ContractException.class, + () -> new MaterialIdAdditionEvent(null)); + assertEquals(MaterialsError.NULL_MATERIAL_ID, contractException.getErrorType()); + } + + @Test + @UnitTestMethod(name = "getMaterialId", args = {}) + public void testGetMaterialId() { + MaterialId materialId = TestMaterialId.MATERIAL_1; + MaterialIdAdditionEvent event = new MaterialIdAdditionEvent(materialId); + + assertNotNull(event); + assertEquals(materialId, event.getMaterialId()); + } +} diff --git a/gcm4/src/test/java/plugins/materials/events/AT_MaterialsProducerAdditionEvent.java b/gcm4/src/test/java/plugins/materials/events/AT_MaterialsProducerAdditionEvent.java new file mode 100644 index 000000000..1e50aacc6 --- /dev/null +++ b/gcm4/src/test/java/plugins/materials/events/AT_MaterialsProducerAdditionEvent.java @@ -0,0 +1,159 @@ +package plugins.materials.events; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.math3.random.RandomGenerator; +import org.junit.jupiter.api.Test; + +import plugins.materials.support.MaterialsError; +import plugins.materials.support.MaterialsProducerId; +import plugins.materials.testsupport.TestMaterialsProducerId; +import tools.annotations.UnitTest; +import tools.annotations.UnitTestMethod; +import util.errors.ContractException; +import util.random.RandomGeneratorProvider; + +@UnitTest(target = MaterialsProducerAdditionEvent.class) +public class AT_MaterialsProducerAdditionEvent { + + @Test + @UnitTestMethod(name = "builder", args = {}) + public void testBuilder() { + MaterialsProducerAdditionEvent.Builder builder = MaterialsProducerAdditionEvent.builder(); + assertNotNull(builder); + } + + @Test + @UnitTestMethod(name = "getMaterialsProducerId", args = {}) + public void testGetMaterialsProdcuerId() { + MaterialsProducerAdditionEvent.Builder builder = MaterialsProducerAdditionEvent.builder(); + MaterialsProducerId producerId = TestMaterialsProducerId.MATERIALS_PRODUCER_1; + + builder.setMaterialsProducerId(producerId); + + MaterialsProducerAdditionEvent event = builder.build(); + assertNotNull(event); + + assertEquals(producerId, event.getMaterialsProducerId()); + } + + @Test + @UnitTestMethod(name = "getValues", args = { Class.class }) + public void testGetValues() { + RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(2177130500877054468L); + MaterialsProducerAdditionEvent.Builder builder = MaterialsProducerAdditionEvent.builder(); + MaterialsProducerId producerId = TestMaterialsProducerId.MATERIALS_PRODUCER_1; + + builder.setMaterialsProducerId(producerId); + + List expectedIntegerValues = new ArrayList<>(); + List expectedStringValues = new ArrayList<>(); + + for (int i = 0; i < 15; i++) { + int integerVal = randomGenerator.nextInt(100); + String stringVal = Integer.toString(integerVal); + builder.addValue(integerVal); + expectedIntegerValues.add(integerVal); + builder.addValue(stringVal); + expectedStringValues.add(stringVal); + } + + MaterialsProducerAdditionEvent event = builder.build(); + assertNotNull(event); + + List actualIntegerValues = event.getValues(Integer.class); + List actualStringValues = event.getValues(String.class); + + assertEquals(expectedIntegerValues.size(), actualIntegerValues.size()); + assertEquals(expectedIntegerValues, actualIntegerValues); + + assertEquals(expectedStringValues.size(), actualStringValues.size()); + assertEquals(expectedStringValues, actualStringValues); + + assertEquals(0, event.getValues(Double.class).size()); + } + + @Test + @UnitTestMethod(target = MaterialsProducerAdditionEvent.Builder.class, name = "build", args = {}) + public void testBuild() { + MaterialsProducerAdditionEvent.Builder builder = MaterialsProducerAdditionEvent.builder(); + MaterialsProducerId producerId = TestMaterialsProducerId.MATERIALS_PRODUCER_1; + + builder.setMaterialsProducerId(producerId); + + MaterialsProducerAdditionEvent event = builder.build(); + assertNotNull(event); + + // precondition: null materials producer id + MaterialsProducerId nProducerId = null; + ContractException contractException = assertThrows(ContractException.class, + () -> MaterialsProducerAdditionEvent.builder().setMaterialsProducerId(nProducerId).build()); + assertEquals(MaterialsError.NULL_MATERIALS_PRODUCER_ID, contractException.getErrorType()); + } + + @Test + @UnitTestMethod(target = MaterialsProducerAdditionEvent.Builder.class, name = "addValue", args = { Object.class }) + public void testAddValue() { + RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(5464369416326792932L); + MaterialsProducerAdditionEvent.Builder builder = MaterialsProducerAdditionEvent.builder(); + MaterialsProducerId producerId = TestMaterialsProducerId.MATERIALS_PRODUCER_1; + + builder.setMaterialsProducerId(producerId); + + List expectedIntegerValues = new ArrayList<>(); + List expectedStringValues = new ArrayList<>(); + + for (int i = 0; i < 15; i++) { + int integerVal = randomGenerator.nextInt(100); + String stringVal = Integer.toString(integerVal); + builder.addValue(integerVal); + expectedIntegerValues.add(integerVal); + builder.addValue(stringVal); + expectedStringValues.add(stringVal); + } + + MaterialsProducerAdditionEvent event = builder.build(); + assertNotNull(event); + + List actualIntegerValues = event.getValues(Integer.class); + List actualStringValues = event.getValues(String.class); + + assertEquals(expectedIntegerValues.size(), actualIntegerValues.size()); + assertEquals(expectedIntegerValues, actualIntegerValues); + + assertEquals(expectedStringValues.size(), actualStringValues.size()); + assertEquals(expectedStringValues, actualStringValues); + + assertEquals(0, event.getValues(Double.class).size()); + + // precondition: value is null + ContractException contractException = assertThrows(ContractException.class, + () -> MaterialsProducerAdditionEvent.builder().addValue(null)); + assertEquals(MaterialsError.NULL_AUXILIARY_DATA, contractException.getErrorType()); + } + + @Test + @UnitTestMethod(target = MaterialsProducerAdditionEvent.Builder.class, name = "setMaterialsProducerId", args = { + MaterialsProducerId.class }) + public void testSetMaterialsProducerId() { + MaterialsProducerAdditionEvent.Builder builder = MaterialsProducerAdditionEvent.builder(); + MaterialsProducerId producerId = TestMaterialsProducerId.MATERIALS_PRODUCER_1; + + builder.setMaterialsProducerId(producerId); + + MaterialsProducerAdditionEvent event = builder.build(); + assertNotNull(event); + + assertEquals(producerId, event.getMaterialsProducerId()); + + // precondition: null materials producer id + ContractException contractException = assertThrows(ContractException.class, + () -> MaterialsProducerAdditionEvent.builder().setMaterialsProducerId(null)); + assertEquals(MaterialsError.NULL_MATERIALS_PRODUCER_ID, contractException.getErrorType()); + } +} diff --git a/gcm4/src/test/java/plugins/materials/events/AT_MaterialsProducerPropertyDefinitionEvent.java b/gcm4/src/test/java/plugins/materials/events/AT_MaterialsProducerPropertyDefinitionEvent.java new file mode 100644 index 000000000..8026b6212 --- /dev/null +++ b/gcm4/src/test/java/plugins/materials/events/AT_MaterialsProducerPropertyDefinitionEvent.java @@ -0,0 +1,45 @@ +package plugins.materials.events; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.junit.jupiter.api.Test; + +import plugins.materials.support.MaterialsProducerPropertyId; +import plugins.materials.testsupport.TestMaterialsProducerPropertyId; +import plugins.util.properties.PropertyError; +import tools.annotations.UnitTest; +import tools.annotations.UnitTestConstructor; +import tools.annotations.UnitTestMethod; +import util.errors.ContractException; + +@UnitTest(target = MaterialsProducerPropertyDefinitionEvent.class) +public class AT_MaterialsProducerPropertyDefinitionEvent { + + @Test + @UnitTestConstructor(args = { MaterialsProducerPropertyId.class }) + public void testConstructor() { + MaterialsProducerPropertyId producerPropertyId = TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_2_INTEGER_MUTABLE_NO_TRACK; + MaterialsProducerPropertyDefinitionEvent event = new MaterialsProducerPropertyDefinitionEvent( + producerPropertyId); + + assertNotNull(event); + // precondition: null producer property id + ContractException contractException = assertThrows(ContractException.class, + () -> new MaterialsProducerPropertyDefinitionEvent(null)); + assertEquals(PropertyError.NULL_PROPERTY_ID, contractException.getErrorType()); + } + + @Test + @UnitTestMethod(name = "getProducerPropertyId", args = {}) + public void testGetProducerPropertyId() { + MaterialsProducerPropertyId producerPropertyId = TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_2_INTEGER_MUTABLE_NO_TRACK; + MaterialsProducerPropertyDefinitionEvent event = new MaterialsProducerPropertyDefinitionEvent( + producerPropertyId); + + assertNotNull(event); + + assertEquals(producerPropertyId, event.getProducerPropertyId()); + } +} diff --git a/gcm4/src/test/java/plugins/materials/events/AT_StageAdditionEvent.java b/gcm4/src/test/java/plugins/materials/events/AT_StageAdditionEvent.java index fc1eceeb8..99f33d320 100644 --- a/gcm4/src/test/java/plugins/materials/events/AT_StageAdditionEvent.java +++ b/gcm4/src/test/java/plugins/materials/events/AT_StageAdditionEvent.java @@ -4,14 +4,13 @@ import org.junit.jupiter.api.Test; -import nucleus.Event; import plugins.materials.support.StageId; import tools.annotations.UnitTest; import tools.annotations.UnitTestConstructor; import tools.annotations.UnitTestMethod; @UnitTest(target = StageAdditionEvent.class) -public class AT_StageAdditionEvent implements Event { +public class AT_StageAdditionEvent { @Test diff --git a/gcm4/src/test/java/plugins/materials/support/AT_BatchConstructionInfo.java b/gcm4/src/test/java/plugins/materials/support/AT_BatchConstructionInfo.java index d01426def..14752118e 100644 --- a/gcm4/src/test/java/plugins/materials/support/AT_BatchConstructionInfo.java +++ b/gcm4/src/test/java/plugins/materials/support/AT_BatchConstructionInfo.java @@ -35,10 +35,10 @@ public void testBuilder() { public void testBuild() { BatchConstructionInfo batchConstructionInfo = // - BatchConstructionInfo .builder()// - .setMaterialId(TestMaterialId.MATERIAL_1)// - .setMaterialsProducerId(TestMaterialsProducerId.MATERIALS_PRODUCER_1)// - .build(); + BatchConstructionInfo.builder()// + .setMaterialId(TestMaterialId.MATERIAL_1)// + .setMaterialsProducerId(TestMaterialsProducerId.MATERIALS_PRODUCER_1)// + .build(); assertNotNull(batchConstructionInfo); assertEquals(0, batchConstructionInfo.getAmount()); assertEquals(TestMaterialId.MATERIAL_1, batchConstructionInfo.getMaterialId()); @@ -47,17 +47,17 @@ public void testBuild() { // precondition test : if the material id was not set ContractException contractException = assertThrows(ContractException.class, () -> // - BatchConstructionInfo .builder()// - .setMaterialsProducerId(TestMaterialsProducerId.MATERIALS_PRODUCER_1)// - .build());// + BatchConstructionInfo.builder()// + .setMaterialsProducerId(TestMaterialsProducerId.MATERIALS_PRODUCER_1)// + .build());// assertEquals(MaterialsError.NULL_MATERIAL_ID, contractException.getErrorType()); // precondition test: if the materials producer id was not set contractException = assertThrows(ContractException.class, () -> // - BatchConstructionInfo .builder()// - .setMaterialId(TestMaterialId.MATERIAL_1)// - .build());// + BatchConstructionInfo.builder()// + .setMaterialId(TestMaterialId.MATERIAL_1)// + .build());// assertEquals(MaterialsError.NULL_MATERIALS_PRODUCER_ID, contractException.getErrorType()); @@ -73,42 +73,42 @@ public void testSetAmount() { for (int i = 0; i < 10; i++) { double amount = 1000 * i; - BatchConstructionInfo batchConstructionInfo = BatchConstructionInfo .builder()// - .setMaterialsProducerId(TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator))// - .setMaterialId(TestMaterialId.getRandomMaterialId(randomGenerator)) // - .setAmount(amount)// - .build();// + BatchConstructionInfo batchConstructionInfo = BatchConstructionInfo.builder()// + .setMaterialsProducerId(TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator))// + .setMaterialId(TestMaterialId.getRandomMaterialId(randomGenerator)) // + .setAmount(amount)// + .build();// assertEquals(amount, batchConstructionInfo.getAmount()); } // precondition test: if the amount is negative ContractException contractException = assertThrows(ContractException.class, // - () -> BatchConstructionInfo .builder()// - .setMaterialsProducerId(TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator))// - .setMaterialId(TestMaterialId.getRandomMaterialId(randomGenerator)) // - .setAmount(-1.0)// - .build()// + () -> BatchConstructionInfo.builder()// + .setMaterialsProducerId(TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator))// + .setMaterialId(TestMaterialId.getRandomMaterialId(randomGenerator)) // + .setAmount(-1.0)// + .build()// ); assertEquals(MaterialsError.NEGATIVE_MATERIAL_AMOUNT, contractException.getErrorType()); // if the amount is not finite contractException = assertThrows(ContractException.class, // - () -> BatchConstructionInfo .builder()// - .setMaterialsProducerId(TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator))// - .setMaterialId(TestMaterialId.getRandomMaterialId(randomGenerator)) // - .setAmount(Double.POSITIVE_INFINITY)// - .build()// + () -> BatchConstructionInfo.builder()// + .setMaterialsProducerId(TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator))// + .setMaterialId(TestMaterialId.getRandomMaterialId(randomGenerator)) // + .setAmount(Double.POSITIVE_INFINITY)// + .build()// ); assertEquals(MaterialsError.NON_FINITE_MATERIAL_AMOUNT, contractException.getErrorType()); contractException = assertThrows(ContractException.class, // - () -> BatchConstructionInfo .builder()// - .setMaterialsProducerId(TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator))// - .setMaterialId(TestMaterialId.getRandomMaterialId(randomGenerator)) // - .setAmount(Double.NaN)// - .build()// + () -> BatchConstructionInfo.builder()// + .setMaterialsProducerId(TestMaterialsProducerId.getRandomMaterialsProducerId(randomGenerator))// + .setMaterialId(TestMaterialId.getRandomMaterialId(randomGenerator)) // + .setAmount(Double.NaN)// + .build()// ); assertEquals(MaterialsError.NON_FINITE_MATERIAL_AMOUNT, contractException.getErrorType()); @@ -118,34 +118,73 @@ public void testSetAmount() { @UnitTestMethod(target = BatchConstructionInfo.Builder.class, name = "setMaterialId", args = { MaterialId.class }) public void testSetMaterialId() { for (TestMaterialId testMaterialId : TestMaterialId.values()) { - BatchConstructionInfo batchConstructionInfo = BatchConstructionInfo .builder()// - .setMaterialId(testMaterialId)// - .setMaterialsProducerId(TestMaterialsProducerId.MATERIALS_PRODUCER_1).build();// + BatchConstructionInfo batchConstructionInfo = BatchConstructionInfo.builder()// + .setMaterialId(testMaterialId)// + .setMaterialsProducerId(TestMaterialsProducerId.MATERIALS_PRODUCER_1).build();// assertEquals(testMaterialId, batchConstructionInfo.getMaterialId()); } // precondition test: if the material id is null ContractException contractException = assertThrows(ContractException.class, () -> // - BatchConstructionInfo .builder()// - .setMaterialId(null)// - .setMaterialsProducerId(TestMaterialsProducerId.MATERIALS_PRODUCER_1).build()// + BatchConstructionInfo.builder()// + .setMaterialId(null)// + .setMaterialsProducerId(TestMaterialsProducerId.MATERIALS_PRODUCER_1).build()// ); assertEquals(MaterialsError.NULL_MATERIAL_ID, contractException.getErrorType()); } @Test - @UnitTestMethod(target = BatchConstructionInfo.Builder.class, name = "setPropertyValue", args = { BatchPropertyId.class, Object.class }) + @UnitTestMethod(name = "getMaterialsProducerId", args = {}) + public void testGetMaterialsProdcuerId() { + BatchConstructionInfo.Builder builder = BatchConstructionInfo.builder(); + MaterialId materialId = TestMaterialId.MATERIAL_2; + MaterialsProducerId producerId = TestMaterialsProducerId.MATERIALS_PRODUCER_2; + + builder.setMaterialId(materialId).setMaterialsProducerId(producerId); + + BatchConstructionInfo info = builder.build(); + assertNotNull(info); + + assertEquals(producerId, info.getMaterialsProducerId()); + } + + @Test + @UnitTestMethod(target = BatchConstructionInfo.Builder.class, name = "setMaterialsProducerId", args = { + MaterialsProducerId.class }) + public void testSetMaterialsProducerId() { + BatchConstructionInfo.Builder builder = BatchConstructionInfo.builder(); + MaterialId materialId = TestMaterialId.MATERIAL_1; + MaterialsProducerId producerId = TestMaterialsProducerId.MATERIALS_PRODUCER_1; + + builder.setMaterialId(materialId).setMaterialsProducerId(producerId); + + BatchConstructionInfo info = builder.build(); + assertNotNull(info); + + assertEquals(producerId, info.getMaterialsProducerId()); + + // precondition: null materials producer id + ContractException contractException = assertThrows(ContractException.class, () -> // + BatchConstructionInfo.builder()// + .setMaterialsProducerId(null)// + ); + assertEquals(MaterialsError.NULL_MATERIALS_PRODUCER_ID, contractException.getErrorType()); + } + + @Test + @UnitTestMethod(target = BatchConstructionInfo.Builder.class, name = "setPropertyValue", args = { + BatchPropertyId.class, Object.class }) public void testSetPropertyValue() { RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(1174771995707697849L); BatchConstructionInfo.Builder builder = BatchConstructionInfo.builder();// for (TestMaterialsProducerId testMaterialsProducerId : TestMaterialsProducerId.values()) { for (TestMaterialId testMaterialId : TestMaterialId.values()) { - builder.setMaterialId(testMaterialId);// - builder.setMaterialsProducerId(testMaterialsProducerId);// + builder.setMaterialId(testMaterialId).setMaterialsProducerId(testMaterialsProducerId);// Map expectedPropertyValues = new LinkedHashMap<>(); - for (TestBatchPropertyId testBatchPropertyId : TestBatchPropertyId.getTestBatchPropertyIds(testMaterialId)) { + for (TestBatchPropertyId testBatchPropertyId : TestBatchPropertyId + .getTestBatchPropertyIds(testMaterialId)) { Object value = testBatchPropertyId.getRandomPropertyValue(randomGenerator); expectedPropertyValues.put(testBatchPropertyId, value); builder.setPropertyValue(testBatchPropertyId, value);// @@ -159,11 +198,13 @@ public void testSetPropertyValue() { } // precondition test: if the property id is null - ContractException contractException = assertThrows(ContractException.class, () -> BatchConstructionInfo.builder().setPropertyValue(null, 15)); + ContractException contractException = assertThrows(ContractException.class, + () -> BatchConstructionInfo.builder().setPropertyValue(null, 15)); assertEquals(PropertyError.NULL_PROPERTY_ID, contractException.getErrorType()); // precondition test: if the property value is null - contractException = assertThrows(ContractException.class, () -> BatchConstructionInfo.builder().setPropertyValue(TestBatchPropertyId.BATCH_PROPERTY_1_1_BOOLEAN_IMMUTABLE_NO_TRACK, null)); + contractException = assertThrows(ContractException.class, () -> BatchConstructionInfo.builder() + .setPropertyValue(TestBatchPropertyId.BATCH_PROPERTY_1_1_BOOLEAN_IMMUTABLE_NO_TRACK, null)); assertEquals(PropertyError.NULL_PROPERTY_VALUE, contractException.getErrorType()); } @@ -173,11 +214,11 @@ public void testSetPropertyValue() { public void testGetMaterialId() { for (TestMaterialId testMaterialId : TestMaterialId.values()) { - BatchConstructionInfo batchConstructionInfo = BatchConstructionInfo .builder()// - .setMaterialId(TestMaterialId.MATERIAL_3)// - .setMaterialsProducerId(TestMaterialsProducerId.MATERIALS_PRODUCER_1)// - .setMaterialId(testMaterialId)// - .build();// + BatchConstructionInfo batchConstructionInfo = BatchConstructionInfo.builder()// + .setMaterialId(TestMaterialId.MATERIAL_3)// + .setMaterialsProducerId(TestMaterialsProducerId.MATERIALS_PRODUCER_1)// + .setMaterialId(testMaterialId)// + .build();// assertEquals(testMaterialId, batchConstructionInfo.getMaterialId()); } } @@ -187,10 +228,10 @@ public void testGetMaterialId() { public void testGetAmount() { for (int i = 0; i < 10; i++) { double amount = 1000 * i; - BatchConstructionInfo batchConstructionInfo = BatchConstructionInfo .builder()// - .setMaterialId(TestMaterialId.MATERIAL_1)// - .setMaterialsProducerId(TestMaterialsProducerId.MATERIALS_PRODUCER_2).setAmount(amount)// - .build();// + BatchConstructionInfo batchConstructionInfo = BatchConstructionInfo.builder()// + .setMaterialId(TestMaterialId.MATERIAL_1)// + .setMaterialsProducerId(TestMaterialsProducerId.MATERIALS_PRODUCER_2).setAmount(amount)// + .build();// assertEquals(amount, batchConstructionInfo.getAmount()); } } @@ -203,11 +244,11 @@ public void testGetPropertyValues() { BatchConstructionInfo.Builder builder = BatchConstructionInfo.builder();// for (TestMaterialsProducerId testMaterialsProducerId : TestMaterialsProducerId.values()) { for (TestMaterialId testMaterialId : TestMaterialId.values()) { - builder.setMaterialsProducerId(testMaterialsProducerId); - builder.setMaterialId(testMaterialId);// + builder.setMaterialsProducerId(testMaterialsProducerId).setMaterialId(testMaterialId);// Map expectedPropertyValues = new LinkedHashMap<>(); - for (TestBatchPropertyId testBatchPropertyId : TestBatchPropertyId.getTestBatchPropertyIds(testMaterialId)) { + for (TestBatchPropertyId testBatchPropertyId : TestBatchPropertyId + .getTestBatchPropertyIds(testMaterialId)) { Object value = testBatchPropertyId.getRandomPropertyValue(randomGenerator); expectedPropertyValues.put(testBatchPropertyId, value); builder.setPropertyValue(testBatchPropertyId, value);// diff --git a/gcm4/src/test/java/plugins/materials/support/AT_BatchPropertyDefinitionInitialization.java b/gcm4/src/test/java/plugins/materials/support/AT_BatchPropertyDefinitionInitialization.java new file mode 100644 index 000000000..bb47b14a7 --- /dev/null +++ b/gcm4/src/test/java/plugins/materials/support/AT_BatchPropertyDefinitionInitialization.java @@ -0,0 +1,352 @@ +package plugins.materials.support; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.math3.random.RandomGenerator; +import org.apache.commons.math3.util.Pair; +import org.junit.jupiter.api.Test; + +import plugins.materials.testsupport.TestBatchPropertyId; +import plugins.materials.testsupport.TestMaterialId; +import plugins.util.properties.PropertyDefinition; +import plugins.util.properties.PropertyError; +import plugins.util.properties.TimeTrackingPolicy; +import tools.annotations.UnitTest; +import tools.annotations.UnitTestMethod; +import util.errors.ContractException; +import util.random.RandomGeneratorProvider; + +@UnitTest(target = BatchPropertyDefinitionInitialization.class) +public class AT_BatchPropertyDefinitionInitialization { + @Test + @UnitTestMethod(name = "builder", args = {}) + public void testBuilder() { + BatchPropertyDefinitionInitialization.Builder builder = BatchPropertyDefinitionInitialization.builder(); + assertNotNull(builder); + } + + @Test + @UnitTestMethod(name = "getPropertyDefinition", args = {}) + public void testGetPropertyDefinition() { + PropertyDefinition propertyDefinition = PropertyDefinition.builder() + .setDefaultValue(100) + .setPropertyValueMutability(false) + .setTimeTrackingPolicy(TimeTrackingPolicy.TRACK_TIME) + .setType(Integer.class) + .build(); + + BatchPropertyId batchPropertyId = TestBatchPropertyId.BATCH_PROPERTY_2_2_INTEGER_IMMUTABLE_TRACK; + MaterialId materialId = TestMaterialId.MATERIAL_1; + + BatchPropertyDefinitionInitialization.Builder builder = BatchPropertyDefinitionInitialization.builder() + .setMaterialId(materialId) + .setPropertyId(batchPropertyId) + .setPropertyDefinition(propertyDefinition); + + BatchPropertyDefinitionInitialization definitionInitialization = builder.build(); + + assertNotNull(definitionInitialization); + assertEquals(propertyDefinition, definitionInitialization.getPropertyDefinition()); + } + + @Test + @UnitTestMethod(name = "getPropertyId", args = {}) + public void testGetPropertyId() { + PropertyDefinition propertyDefinition = PropertyDefinition.builder() + .setDefaultValue(100) + .setPropertyValueMutability(false) + .setTimeTrackingPolicy(TimeTrackingPolicy.TRACK_TIME) + .setType(Integer.class) + .build(); + + BatchPropertyId batchPropertyId = TestBatchPropertyId.BATCH_PROPERTY_2_2_INTEGER_IMMUTABLE_TRACK; + MaterialId materialId = TestMaterialId.MATERIAL_1; + + BatchPropertyDefinitionInitialization.Builder builder = BatchPropertyDefinitionInitialization.builder() + .setMaterialId(materialId) + .setPropertyId(batchPropertyId) + .setPropertyDefinition(propertyDefinition); + + BatchPropertyDefinitionInitialization definitionInitialization = builder.build(); + + assertNotNull(definitionInitialization); + assertEquals(batchPropertyId, definitionInitialization.getPropertyId()); + } + + @Test + @UnitTestMethod(name = "getPropertyValues", args = {}) + public void testGetPropertyValues() { + RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(8487271708488687492L); + PropertyDefinition propertyDefinition = PropertyDefinition.builder() + .setDefaultValue("100") + .setPropertyValueMutability(false) + .setTimeTrackingPolicy(TimeTrackingPolicy.TRACK_TIME) + .setType(String.class) + .build(); + + BatchPropertyId batchPropertyId = TestBatchPropertyId.BATCH_PROPERTY_2_2_INTEGER_IMMUTABLE_TRACK; + MaterialId materialId = TestMaterialId.MATERIAL_1; + + BatchPropertyDefinitionInitialization.Builder builder = BatchPropertyDefinitionInitialization.builder() + .setMaterialId(materialId) + .setPropertyId(batchPropertyId) + .setPropertyDefinition(propertyDefinition); + + List> expectedValues = new ArrayList<>(); + for (int i = 0; i < 15; i++) { + String value = Integer.toString(randomGenerator.nextInt(100)); + BatchId batchId = new BatchId(i); + builder.addPropertyValue(batchId, value); + expectedValues.add(new Pair<>(batchId, value)); + } + + BatchPropertyDefinitionInitialization definitionInitialization = builder.build(); + + assertNotNull(definitionInitialization); + assertEquals(expectedValues.size(), definitionInitialization.getPropertyValues().size()); + assertEquals(expectedValues, definitionInitialization.getPropertyValues()); + + } + + @Test + @UnitTestMethod(name = "getMaterialId", args = {}) + public void testGetMaterialId() { + PropertyDefinition propertyDefinition = PropertyDefinition.builder() + .setDefaultValue(100) + .setPropertyValueMutability(false) + .setTimeTrackingPolicy(TimeTrackingPolicy.TRACK_TIME) + .setType(Integer.class) + .build(); + + BatchPropertyId batchPropertyId = TestBatchPropertyId.BATCH_PROPERTY_2_2_INTEGER_IMMUTABLE_TRACK; + MaterialId materialId = TestMaterialId.MATERIAL_1; + + BatchPropertyDefinitionInitialization.Builder builder = BatchPropertyDefinitionInitialization.builder() + .setMaterialId(materialId) + .setPropertyId(batchPropertyId) + .setPropertyDefinition(propertyDefinition); + + BatchPropertyDefinitionInitialization definitionInitialization = builder.build(); + + assertNotNull(definitionInitialization); + assertEquals(materialId, definitionInitialization.getMaterialId()); + } + + @Test + @UnitTestMethod(target = BatchPropertyDefinitionInitialization.Builder.class, name = "build", args = {}) + public void testBuild() { + RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(8487271708488687492L); + PropertyDefinition propertyDefinition = PropertyDefinition.builder() + .setDefaultValue("100") + .setPropertyValueMutability(false) + .setTimeTrackingPolicy(TimeTrackingPolicy.TRACK_TIME) + .setType(String.class) + .build(); + + BatchPropertyId batchPropertyId = TestBatchPropertyId.BATCH_PROPERTY_2_2_INTEGER_IMMUTABLE_TRACK; + MaterialId materialId = TestMaterialId.MATERIAL_1; + + BatchPropertyDefinitionInitialization.Builder builder = BatchPropertyDefinitionInitialization.builder() + .setMaterialId(materialId) + .setPropertyId(batchPropertyId) + .setPropertyDefinition(propertyDefinition); + + List> expectedValues = new ArrayList<>(); + for (int i = 0; i < 15; i++) { + String value = Integer.toString(randomGenerator.nextInt(100)); + BatchId batchId = new BatchId(i); + builder.addPropertyValue(batchId, value); + expectedValues.add(new Pair<>(batchId, value)); + } + + BatchPropertyDefinitionInitialization definitionInitialization = builder.build(); + + assertNotNull(definitionInitialization); + + // precondition: null property definition + PropertyDefinition nPropertyDefinition = null; + ContractException contractException = assertThrows(ContractException.class, + () -> BatchPropertyDefinitionInitialization.builder() + .setMaterialId(materialId) + .setPropertyId(batchPropertyId) + .setPropertyDefinition(nPropertyDefinition) + .build()); + assertEquals(PropertyError.NULL_PROPERTY_DEFINITION, contractException.getErrorType()); + + // precondition: null property id + BatchPropertyId nBatchPropertyId = null; + contractException = assertThrows(ContractException.class, + () -> BatchPropertyDefinitionInitialization.builder() + .setMaterialId(materialId) + .setPropertyId(nBatchPropertyId) + .setPropertyDefinition(propertyDefinition) + .build()); + assertEquals(PropertyError.NULL_PROPERTY_ID, contractException.getErrorType()); + + // precondition: null material id + MaterialId nMaterialId = null; + contractException = assertThrows(ContractException.class, + () -> BatchPropertyDefinitionInitialization.builder() + .setMaterialId(nMaterialId) + .setPropertyId(batchPropertyId) + .setPropertyDefinition(propertyDefinition) + .build()); + assertEquals(MaterialsError.NULL_MATERIAL_ID, contractException.getErrorType()); + + // precondition: incomaptible value + contractException = assertThrows(ContractException.class, + () -> BatchPropertyDefinitionInitialization.builder() + .setMaterialId(materialId) + .setPropertyId(batchPropertyId) + .setPropertyDefinition(propertyDefinition) + .addPropertyValue(new BatchId(0), 100) + .build()); + assertEquals(PropertyError.INCOMPATIBLE_VALUE, contractException.getErrorType()); + + } + + @Test + @UnitTestMethod(target = BatchPropertyDefinitionInitialization.Builder.class, name = "setPropertyDefinition", args = { + PropertyDefinition.class }) + public void testSetPropertyDefinition() { + PropertyDefinition propertyDefinition = PropertyDefinition.builder() + .setDefaultValue(100) + .setPropertyValueMutability(false) + .setTimeTrackingPolicy(TimeTrackingPolicy.TRACK_TIME) + .setType(Integer.class) + .build(); + + BatchPropertyId batchPropertyId = TestBatchPropertyId.BATCH_PROPERTY_2_2_INTEGER_IMMUTABLE_TRACK; + MaterialId materialId = TestMaterialId.MATERIAL_1; + + BatchPropertyDefinitionInitialization.Builder builder = BatchPropertyDefinitionInitialization.builder() + .setMaterialId(materialId) + .setPropertyId(batchPropertyId) + .setPropertyDefinition(propertyDefinition); + + BatchPropertyDefinitionInitialization definitionInitialization = builder.build(); + + assertNotNull(definitionInitialization); + assertEquals(propertyDefinition, definitionInitialization.getPropertyDefinition()); + + // precondition: null property definition + ContractException contractException = assertThrows(ContractException.class, + () -> BatchPropertyDefinitionInitialization.builder() + .setPropertyDefinition(null)); + assertEquals(PropertyError.NULL_PROPERTY_DEFINITION, contractException.getErrorType()); + } + + @Test + @UnitTestMethod(target = BatchPropertyDefinitionInitialization.Builder.class, name = "setPropertyId", args = { + BatchPropertyId.class }) + public void testSetPropertyId() { + PropertyDefinition propertyDefinition = PropertyDefinition.builder() + .setDefaultValue(100) + .setPropertyValueMutability(false) + .setTimeTrackingPolicy(TimeTrackingPolicy.TRACK_TIME) + .setType(Integer.class) + .build(); + + BatchPropertyId batchPropertyId = TestBatchPropertyId.BATCH_PROPERTY_2_2_INTEGER_IMMUTABLE_TRACK; + MaterialId materialId = TestMaterialId.MATERIAL_1; + + BatchPropertyDefinitionInitialization.Builder builder = BatchPropertyDefinitionInitialization.builder() + .setMaterialId(materialId) + .setPropertyId(batchPropertyId) + .setPropertyDefinition(propertyDefinition); + + BatchPropertyDefinitionInitialization definitionInitialization = builder.build(); + + assertNotNull(definitionInitialization); + assertEquals(batchPropertyId, definitionInitialization.getPropertyId()); + + // precondition: null property id + ContractException contractException = assertThrows(ContractException.class, + () -> BatchPropertyDefinitionInitialization.builder() + .setPropertyId(null)); + assertEquals(PropertyError.NULL_PROPERTY_ID, contractException.getErrorType()); + } + + @Test + @UnitTestMethod(target = BatchPropertyDefinitionInitialization.Builder.class, name = "addPropertyValue", args = { + BatchId.class, Object.class }) + public void testAddPropertyValue() { + RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(8487271708488687492L); + PropertyDefinition propertyDefinition = PropertyDefinition.builder() + .setDefaultValue("100") + .setPropertyValueMutability(false) + .setTimeTrackingPolicy(TimeTrackingPolicy.TRACK_TIME) + .setType(String.class) + .build(); + + BatchPropertyId batchPropertyId = TestBatchPropertyId.BATCH_PROPERTY_2_2_INTEGER_IMMUTABLE_TRACK; + MaterialId materialId = TestMaterialId.MATERIAL_1; + + BatchPropertyDefinitionInitialization.Builder builder = BatchPropertyDefinitionInitialization.builder() + .setMaterialId(materialId) + .setPropertyId(batchPropertyId) + .setPropertyDefinition(propertyDefinition); + + List> expectedValues = new ArrayList<>(); + for (int i = 0; i < 15; i++) { + String value = Integer.toString(randomGenerator.nextInt(100)); + BatchId batchId = new BatchId(i); + builder.addPropertyValue(batchId, value); + expectedValues.add(new Pair<>(batchId, value)); + } + + BatchPropertyDefinitionInitialization definitionInitialization = builder.build(); + + assertNotNull(definitionInitialization); + assertEquals(expectedValues.size(), definitionInitialization.getPropertyValues().size()); + assertEquals(expectedValues, definitionInitialization.getPropertyValues()); + + // precondition: null batch id + ContractException contractException = assertThrows(ContractException.class, + () -> BatchPropertyDefinitionInitialization.builder() + .addPropertyValue(null, "100")); + assertEquals(MaterialsError.NULL_BATCH_ID, contractException.getErrorType()); + + // precondition: null value + contractException = assertThrows(ContractException.class, + () -> BatchPropertyDefinitionInitialization.builder() + .addPropertyValue(new BatchId(0), null)); + assertEquals(PropertyError.NULL_PROPERTY_VALUE, contractException.getErrorType()); + } + + @Test + @UnitTestMethod(target = BatchPropertyDefinitionInitialization.Builder.class, name = "setMaterialId", args = { + MaterialId.class }) + public void testSetMaterialId() { + PropertyDefinition propertyDefinition = PropertyDefinition.builder() + .setDefaultValue(100) + .setPropertyValueMutability(false) + .setTimeTrackingPolicy(TimeTrackingPolicy.TRACK_TIME) + .setType(Integer.class) + .build(); + + BatchPropertyId batchPropertyId = TestBatchPropertyId.BATCH_PROPERTY_2_2_INTEGER_IMMUTABLE_TRACK; + MaterialId materialId = TestMaterialId.MATERIAL_1; + + BatchPropertyDefinitionInitialization.Builder builder = BatchPropertyDefinitionInitialization.builder() + .setMaterialId(materialId) + .setPropertyId(batchPropertyId) + .setPropertyDefinition(propertyDefinition); + + BatchPropertyDefinitionInitialization definitionInitialization = builder.build(); + + assertNotNull(definitionInitialization); + assertEquals(materialId, definitionInitialization.getMaterialId()); + + // precondition: null material id + ContractException contractException = assertThrows(ContractException.class, + () -> BatchPropertyDefinitionInitialization.builder() + .setMaterialId(null)); + assertEquals(MaterialsError.NULL_MATERIAL_ID, contractException.getErrorType()); + } +} diff --git a/gcm4/src/test/java/plugins/materials/support/AT_MaterialsProducerConstructionData.java b/gcm4/src/test/java/plugins/materials/support/AT_MaterialsProducerConstructionData.java new file mode 100644 index 000000000..49801f5a2 --- /dev/null +++ b/gcm4/src/test/java/plugins/materials/support/AT_MaterialsProducerConstructionData.java @@ -0,0 +1,281 @@ +package plugins.materials.support; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.math3.random.RandomGenerator; +import org.junit.jupiter.api.Test; + +import plugins.materials.testsupport.TestMaterialsProducerId; +import plugins.materials.testsupport.TestMaterialsProducerPropertyId; +import plugins.resources.support.ResourceError; +import plugins.resources.support.ResourceId; +import plugins.resources.testsupport.TestResourceId; +import plugins.util.properties.PropertyError; +import tools.annotations.UnitTest; +import tools.annotations.UnitTestMethod; +import util.errors.ContractException; +import util.random.RandomGeneratorProvider; + +@UnitTest(target = MaterialsProducerConstructionData.class) +public class AT_MaterialsProducerConstructionData { + + @Test + @UnitTestMethod(name = "builder", args = {}) + public void testBuilder() { + MaterialsProducerConstructionData.Builder builder = MaterialsProducerConstructionData.builder(); + + assertNotNull(builder); + } + + @Test + @UnitTestMethod(name = "getValues", args = { Class.class }) + public void testGetValues() { + RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(7180465772129297639L); + MaterialsProducerConstructionData.Builder builder = MaterialsProducerConstructionData.builder(); + builder.setMaterialsProducerId(TestMaterialsProducerId.MATERIALS_PRODUCER_1); + + List expectedIntegers = new ArrayList<>(); + List expectedDoubles = new ArrayList<>(); + for (int i = 0; i < 20; i++) { + if (i % 2 == 0) { + int value = randomGenerator.nextInt(100); + expectedIntegers.add(value); + builder.addValue(value); + } else { + double value = randomGenerator.nextDouble() * 100; + expectedDoubles.add(value); + builder.addValue(value); + } + } + + MaterialsProducerConstructionData constructionData = builder.build(); + assertNotNull(constructionData); + + assertEquals(expectedIntegers, constructionData.getValues(Integer.class)); + assertEquals(expectedDoubles, constructionData.getValues(Double.class)); + + } + + @Test + @UnitTestMethod(name = "getMaterialsProducerId", args = {}) + public void testGetMaterialsProducerId() { + MaterialsProducerConstructionData.Builder builder = MaterialsProducerConstructionData.builder(); + builder.setMaterialsProducerId(TestMaterialsProducerId.MATERIALS_PRODUCER_1); + + MaterialsProducerConstructionData constructionData = builder.build(); + assertNotNull(constructionData); + assertEquals(TestMaterialsProducerId.MATERIALS_PRODUCER_1, constructionData.getMaterialsProducerId()); + } + + @Test + @UnitTestMethod(name = "getMaterialsProducerPropertyValues", args = {}) + public void testGetMaterialsProducerPropertyValues() { + RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(6832539036105490849L); + MaterialsProducerConstructionData.Builder builder = MaterialsProducerConstructionData.builder(); + builder.setMaterialsProducerId(TestMaterialsProducerId.MATERIALS_PRODUCER_1); + + Map expectedValues = new LinkedHashMap<>(); + + for (int i = 0; i < 15; i++) { + TestMaterialsProducerPropertyId producerPropertyId = TestMaterialsProducerPropertyId + .getRandomMaterialsProducerPropertyId(randomGenerator); + if (!expectedValues.containsKey(producerPropertyId)) { + Object value = producerPropertyId.getRandomPropertyValue(randomGenerator); + builder.setMaterialsProducerPropertyValue(producerPropertyId, value); + expectedValues.put(producerPropertyId, value); + } + } + + MaterialsProducerConstructionData constructionData = builder.build(); + assertNotNull(constructionData); + assertEquals(expectedValues, constructionData.getMaterialsProducerPropertyValues()); + } + + @Test + @UnitTestMethod(name = "getResourceLevels", args = {}) + public void testGetResourceLevels() { + RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(6832539036105490849L); + MaterialsProducerConstructionData.Builder builder = MaterialsProducerConstructionData.builder(); + builder.setMaterialsProducerId(TestMaterialsProducerId.MATERIALS_PRODUCER_1); + + Map expectedValues = new LinkedHashMap<>(); + for (int i = 0; i < 15; i++) { + ResourceId resourceId = TestResourceId.getRandomResourceId(randomGenerator); + if (!expectedValues.containsKey(resourceId)) { + long value = randomGenerator.nextInt(100 * (i + 1)) + 1; + builder.setResourceLevel(resourceId, value); + expectedValues.put(resourceId, value); + } + } + + MaterialsProducerConstructionData constructionData = builder.build(); + assertNotNull(constructionData); + assertEquals(expectedValues, constructionData.getResourceLevels()); + + } + + @Test + @UnitTestMethod(target = MaterialsProducerConstructionData.Builder.class, name = "build", args = {}) + public void testBuild() { + MaterialsProducerConstructionData.Builder builder = MaterialsProducerConstructionData.builder(); + builder.setMaterialsProducerId(TestMaterialsProducerId.MATERIALS_PRODUCER_1); + + MaterialsProducerConstructionData constructionData = builder.build(); + assertNotNull(constructionData); + + // precondition: materials producer id is null + ContractException contractException = assertThrows(ContractException.class, + () -> MaterialsProducerConstructionData.builder().build()); + assertEquals(MaterialsError.NULL_MATERIALS_PRODUCER_ID, contractException.getErrorType()); + } + + @Test + @UnitTestMethod(target = MaterialsProducerConstructionData.Builder.class, name = "addValue", args = { + Object.class }) + public void testAddValue() { + RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(8237136898094031982L); + MaterialsProducerConstructionData.Builder builder = MaterialsProducerConstructionData.builder(); + builder.setMaterialsProducerId(TestMaterialsProducerId.MATERIALS_PRODUCER_1); + + List expectedIntegers = new ArrayList<>(); + List expectedDoubles = new ArrayList<>(); + for (int i = 0; i < 20; i++) { + if (i % 2 == 0) { + int value = randomGenerator.nextInt(100); + expectedIntegers.add(value); + builder.addValue(value); + } else { + double value = randomGenerator.nextDouble() * 100; + expectedDoubles.add(value); + builder.addValue(value); + } + } + + MaterialsProducerConstructionData constructionData = builder.build(); + assertNotNull(constructionData); + + assertEquals(expectedIntegers, constructionData.getValues(Integer.class)); + assertEquals(expectedDoubles, constructionData.getValues(Double.class)); + + // precondition: value is null + ContractException contractException = assertThrows(ContractException.class, + () -> MaterialsProducerConstructionData.builder().addValue(null)); + assertEquals(MaterialsError.NULL_AUXILIARY_DATA, contractException.getErrorType()); + } + + @Test + @UnitTestMethod(target = MaterialsProducerConstructionData.Builder.class, name = "setMaterialsProducerPropertyValue", args = { + MaterialsProducerPropertyId.class, Object.class }) + public void testSetMaterialsProducerPropertyValue() { + RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(8800503605965150018L); + MaterialsProducerConstructionData.Builder builder = MaterialsProducerConstructionData.builder(); + builder.setMaterialsProducerId(TestMaterialsProducerId.MATERIALS_PRODUCER_1); + + Map expectedValues = new LinkedHashMap<>(); + + for (int i = 0; i < 15; i++) { + TestMaterialsProducerPropertyId producerPropertyId = TestMaterialsProducerPropertyId + .getRandomMaterialsProducerPropertyId(randomGenerator); + if (!expectedValues.containsKey(producerPropertyId)) { + Object value = producerPropertyId.getRandomPropertyValue(randomGenerator); + builder.setMaterialsProducerPropertyValue(producerPropertyId, value); + expectedValues.put(producerPropertyId, value); + } + } + + MaterialsProducerConstructionData constructionData = builder.build(); + assertNotNull(constructionData); + assertEquals(expectedValues, constructionData.getMaterialsProducerPropertyValues()); + + // precondition: materials producer property id is null + ContractException contractException = assertThrows(ContractException.class, + () -> MaterialsProducerConstructionData.builder() + .setMaterialsProducerPropertyValue(null, "100")); + assertEquals(PropertyError.NULL_PROPERTY_ID, contractException.getErrorType()); + + // precondition: value is null + contractException = assertThrows(ContractException.class, + () -> MaterialsProducerConstructionData.builder() + .setMaterialsProducerPropertyValue( + TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_1_BOOLEAN_MUTABLE_NO_TRACK, + null)); + assertEquals(PropertyError.NULL_PROPERTY_VALUE, contractException.getErrorType()); + + // precondition: duplicate producer property id + contractException = assertThrows(ContractException.class, + () -> MaterialsProducerConstructionData.builder() + .setMaterialsProducerPropertyValue( + TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_1_BOOLEAN_MUTABLE_NO_TRACK, + false) + .setMaterialsProducerPropertyValue( + TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_1_BOOLEAN_MUTABLE_NO_TRACK, + true)); + assertEquals(PropertyError.DUPLICATE_PROPERTY_VALUE_ASSIGNMENT, contractException.getErrorType()); + } + + @Test + @UnitTestMethod(target = MaterialsProducerConstructionData.Builder.class, name = "setMaterialsProducerId", args = { + MaterialsProducerId.class }) + public void testSetMaterialsProducerId() { + MaterialsProducerConstructionData.Builder builder = MaterialsProducerConstructionData.builder(); + builder.setMaterialsProducerId(TestMaterialsProducerId.MATERIALS_PRODUCER_1); + + MaterialsProducerConstructionData constructionData = builder.build(); + assertNotNull(constructionData); + assertEquals(TestMaterialsProducerId.MATERIALS_PRODUCER_1, constructionData.getMaterialsProducerId()); + + // precondition: materials producer id is null + ContractException contractException = assertThrows(ContractException.class, + () -> MaterialsProducerConstructionData.builder().setMaterialsProducerId(null)); + assertEquals(MaterialsError.NULL_MATERIALS_PRODUCER_ID, contractException.getErrorType()); + } + + @Test + @UnitTestMethod(target = MaterialsProducerConstructionData.Builder.class, name = "setResourceLevel", args = { + ResourceId.class, long.class }) + public void testSetResourceLevel() { + RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(6090230296084756769L); + MaterialsProducerConstructionData.Builder builder = MaterialsProducerConstructionData.builder(); + builder.setMaterialsProducerId(TestMaterialsProducerId.MATERIALS_PRODUCER_1); + + Map expectedValues = new LinkedHashMap<>(); + for (int i = 0; i < 15; i++) { + ResourceId resourceId = TestResourceId.getRandomResourceId(randomGenerator); + if (!expectedValues.containsKey(resourceId)) { + long value = randomGenerator.nextInt(100 * (i + 1)) + 1; + builder.setResourceLevel(resourceId, value); + expectedValues.put(resourceId, value); + } + } + + MaterialsProducerConstructionData constructionData = builder.build(); + assertNotNull(constructionData); + assertEquals(expectedValues, constructionData.getResourceLevels()); + + // precondition: resource id is null + ContractException contractException = assertThrows(ContractException.class, + () -> MaterialsProducerConstructionData.builder() + .setResourceLevel(null, 0)); + assertEquals(ResourceError.NULL_RESOURCE_ID, contractException.getErrorType()); + + // precondition: level is negative (< 0) + contractException = assertThrows(ContractException.class, + () -> MaterialsProducerConstructionData.builder() + .setResourceLevel(TestResourceId.RESOURCE_1, -100)); + assertEquals(ResourceError.NEGATIVE_RESOURCE_AMOUNT, contractException.getErrorType()); + + // precondition: duplicate resource id + contractException = assertThrows(ContractException.class, + () -> MaterialsProducerConstructionData.builder() + .setResourceLevel(TestResourceId.RESOURCE_1, 100) + .setResourceLevel(TestResourceId.RESOURCE_1, 100)); + assertEquals(ResourceError.DUPLICATE_REGION_RESOURCE_LEVEL_ASSIGNMENT, contractException.getErrorType()); + } +} diff --git a/gcm4/src/test/java/plugins/materials/support/AT_MaterialsProducerPropertyDefinitionInitialization.java b/gcm4/src/test/java/plugins/materials/support/AT_MaterialsProducerPropertyDefinitionInitialization.java new file mode 100644 index 000000000..a21a3598b --- /dev/null +++ b/gcm4/src/test/java/plugins/materials/support/AT_MaterialsProducerPropertyDefinitionInitialization.java @@ -0,0 +1,270 @@ +package plugins.materials.support; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.math3.random.RandomGenerator; +import org.apache.commons.math3.util.Pair; +import org.junit.jupiter.api.Test; + +import plugins.materials.testsupport.TestMaterialsProducerId; +import plugins.materials.testsupport.TestMaterialsProducerPropertyId; +import plugins.util.properties.PropertyDefinition; +import plugins.util.properties.PropertyError; +import plugins.util.properties.TimeTrackingPolicy; +import tools.annotations.UnitTest; +import tools.annotations.UnitTestMethod; +import util.errors.ContractException; +import util.random.RandomGeneratorProvider; + +@UnitTest(target = MaterialsProducerPropertyDefinitionInitialization.class) +public class AT_MaterialsProducerPropertyDefinitionInitialization { + + @Test + @UnitTestMethod(name = "builder", args = {}) + public void testBuilder() { + MaterialsProducerPropertyDefinitionInitialization.Builder builder = MaterialsProducerPropertyDefinitionInitialization + .builder(); + assertNotNull(builder); + } + + @Test + @UnitTestMethod(name = "getPropertyDefinition", args = {}) + public void testGetPropertyDefinition() { + MaterialsProducerPropertyDefinitionInitialization.Builder builder = MaterialsProducerPropertyDefinitionInitialization + .builder(); + PropertyDefinition propertyDefinition = PropertyDefinition.builder() + .setDefaultValue(100) + .setPropertyValueMutability(false) + .setType(Integer.class) + .setTimeTrackingPolicy(TimeTrackingPolicy.DO_NOT_TRACK_TIME) + .build(); + MaterialsProducerPropertyId producerPropertyId = TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_8_INTEGER_IMMUTABLE_NO_TRACK; + + builder.setPropertyDefinition(propertyDefinition).setMaterialsProducerPropertyId(producerPropertyId); + + MaterialsProducerPropertyDefinitionInitialization definitionInitialization = builder.build(); + + assertNotNull(definitionInitialization); + assertEquals(propertyDefinition, definitionInitialization.getPropertyDefinition()); + + } + + @Test + @UnitTestMethod(name = "getPropertyValues", args = {}) + public void testGetPropertyValues() { + RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(7180465772129297639L); + MaterialsProducerPropertyDefinitionInitialization.Builder builder = MaterialsProducerPropertyDefinitionInitialization + .builder(); + PropertyDefinition propertyDefinition = PropertyDefinition.builder() + .setDefaultValue(100) + .setPropertyValueMutability(false) + .setType(Integer.class) + .setTimeTrackingPolicy(TimeTrackingPolicy.DO_NOT_TRACK_TIME) + .build(); + MaterialsProducerPropertyId producerPropertyId = TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_8_INTEGER_IMMUTABLE_NO_TRACK; + + builder.setPropertyDefinition(propertyDefinition).setMaterialsProducerPropertyId(producerPropertyId); + + List> expectedValues = new ArrayList<>(); + for (int i = 0; i < 15; i++) { + int value = randomGenerator.nextInt(100); + MaterialsProducerId producerId = TestMaterialsProducerId + .getRandomMaterialsProducerId(randomGenerator); + expectedValues.add(new Pair<>(producerId, value)); + builder.addPropertyValue(producerId, value); + } + + MaterialsProducerPropertyDefinitionInitialization definitionInitialization = builder.build(); + List> actualValues = definitionInitialization.getPropertyValues(); + assertNotNull(definitionInitialization); + assertEquals(expectedValues.size(), actualValues.size()); + assertEquals(expectedValues, actualValues); + } + + @Test + @UnitTestMethod(name = "getMaterialsProducerPropertyId", args = {}) + public void testGetMaterialsProducerPropertyId() { + MaterialsProducerPropertyDefinitionInitialization.Builder builder = MaterialsProducerPropertyDefinitionInitialization + .builder(); + PropertyDefinition propertyDefinition = PropertyDefinition.builder() + .setDefaultValue(100) + .setPropertyValueMutability(false) + .setType(Integer.class) + .setTimeTrackingPolicy(TimeTrackingPolicy.DO_NOT_TRACK_TIME) + .build(); + MaterialsProducerPropertyId producerPropertyId = TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_8_INTEGER_IMMUTABLE_NO_TRACK; + + builder.setPropertyDefinition(propertyDefinition).setMaterialsProducerPropertyId(producerPropertyId); + + MaterialsProducerPropertyDefinitionInitialization definitionInitialization = builder.build(); + + assertNotNull(definitionInitialization); + assertEquals(producerPropertyId, definitionInitialization.getMaterialsProducerPropertyId()); + } + + @Test + @UnitTestMethod(target = MaterialsProducerPropertyDefinitionInitialization.Builder.class, name = "build", args = {}) + public void testBuild() { + RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(6087174477323266390L); + MaterialsProducerPropertyDefinitionInitialization.Builder builder = MaterialsProducerPropertyDefinitionInitialization + .builder(); + PropertyDefinition propertyDefinition = PropertyDefinition.builder() + .setDefaultValue(100) + .setPropertyValueMutability(false) + .setType(Integer.class) + .setTimeTrackingPolicy(TimeTrackingPolicy.DO_NOT_TRACK_TIME) + .build(); + MaterialsProducerPropertyId producerPropertyId = TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_8_INTEGER_IMMUTABLE_NO_TRACK; + + builder.setPropertyDefinition(propertyDefinition).setMaterialsProducerPropertyId(producerPropertyId); + + List> expectedValues = new ArrayList<>(); + for (int i = 0; i < 15; i++) { + int value = randomGenerator.nextInt(100); + MaterialsProducerId producerId = TestMaterialsProducerId + .getRandomMaterialsProducerId(randomGenerator); + expectedValues.add(new Pair<>(producerId, value)); + builder.addPropertyValue(producerId, value); + } + + MaterialsProducerPropertyDefinitionInitialization definitionInitialization = builder.build(); + + assertNotNull(definitionInitialization); + + // precondition: propertyDefinition is null + ContractException contractException = assertThrows(ContractException.class, + () -> MaterialsProducerPropertyDefinitionInitialization + .builder() + .setMaterialsProducerPropertyId(producerPropertyId) + .build()); + assertEquals(PropertyError.NULL_PROPERTY_DEFINITION, contractException.getErrorType()); + + // precondition: producer property id is null + contractException = assertThrows(ContractException.class, + () -> MaterialsProducerPropertyDefinitionInitialization + .builder() + .setPropertyDefinition(propertyDefinition) + .build()); + assertEquals(PropertyError.NULL_PROPERTY_ID, contractException.getErrorType()); + + // precondition: incompatible value + contractException = assertThrows(ContractException.class, + () -> MaterialsProducerPropertyDefinitionInitialization + .builder().setMaterialsProducerPropertyId(producerPropertyId) + .setPropertyDefinition(propertyDefinition) + .addPropertyValue(TestMaterialsProducerId + .getRandomMaterialsProducerId(randomGenerator), "100") + .build()); + assertEquals(PropertyError.INCOMPATIBLE_VALUE, contractException.getErrorType()); + } + + @Test + @UnitTestMethod(target = MaterialsProducerPropertyDefinitionInitialization.Builder.class, name = "setPropertyDefinition", args = { + PropertyDefinition.class }) + public void testSetPropertyDefinition() { + MaterialsProducerPropertyDefinitionInitialization.Builder builder = MaterialsProducerPropertyDefinitionInitialization + .builder(); + PropertyDefinition propertyDefinition = PropertyDefinition.builder() + .setDefaultValue(100) + .setPropertyValueMutability(false) + .setType(Integer.class) + .setTimeTrackingPolicy(TimeTrackingPolicy.DO_NOT_TRACK_TIME) + .build(); + MaterialsProducerPropertyId producerPropertyId = TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_8_INTEGER_IMMUTABLE_NO_TRACK; + + builder.setPropertyDefinition(propertyDefinition).setMaterialsProducerPropertyId(producerPropertyId); + + MaterialsProducerPropertyDefinitionInitialization definitionInitialization = builder.build(); + + assertNotNull(definitionInitialization); + assertEquals(propertyDefinition, definitionInitialization.getPropertyDefinition()); + + // precondition: propertyDefinition is null + ContractException contractException = assertThrows(ContractException.class, + () -> MaterialsProducerPropertyDefinitionInitialization + .builder() + .setPropertyDefinition(null)); + assertEquals(PropertyError.NULL_PROPERTY_DEFINITION, contractException.getErrorType()); + } + + @Test + @UnitTestMethod(target = MaterialsProducerPropertyDefinitionInitialization.Builder.class, name = "addPropertyValue", args = { + MaterialsProducerId.class, Object.class }) + public void testAddPropertyValue() { + RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(3968585809330067411L); + MaterialsProducerPropertyDefinitionInitialization.Builder builder = MaterialsProducerPropertyDefinitionInitialization + .builder(); + PropertyDefinition propertyDefinition = PropertyDefinition.builder() + .setDefaultValue(100) + .setPropertyValueMutability(false) + .setType(Integer.class) + .setTimeTrackingPolicy(TimeTrackingPolicy.DO_NOT_TRACK_TIME) + .build(); + MaterialsProducerPropertyId producerPropertyId = TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_8_INTEGER_IMMUTABLE_NO_TRACK; + + builder.setPropertyDefinition(propertyDefinition).setMaterialsProducerPropertyId(producerPropertyId); + + List> expectedValues = new ArrayList<>(); + for (int i = 0; i < 15; i++) { + int value = randomGenerator.nextInt(100); + MaterialsProducerId producerId = TestMaterialsProducerId + .getRandomMaterialsProducerId(randomGenerator); + expectedValues.add(new Pair<>(producerId, value)); + builder.addPropertyValue(producerId, value); + } + + MaterialsProducerPropertyDefinitionInitialization definitionInitialization = builder.build(); + List> actualValues = definitionInitialization.getPropertyValues(); + assertNotNull(definitionInitialization); + assertEquals(expectedValues.size(), actualValues.size()); + assertEquals(expectedValues, actualValues); + + // precondition: producer id is null + ContractException contractException = assertThrows(ContractException.class, + () -> MaterialsProducerPropertyDefinitionInitialization + .builder() + .addPropertyValue(null, 100)); + assertEquals(MaterialsError.NULL_MATERIALS_PRODUCER_ID, contractException.getErrorType()); + + // precondition: value is null + contractException = assertThrows(ContractException.class, + () -> MaterialsProducerPropertyDefinitionInitialization + .builder() + .addPropertyValue(TestMaterialsProducerId.MATERIALS_PRODUCER_1, null)); + assertEquals(PropertyError.NULL_PROPERTY_VALUE, contractException.getErrorType()); + } + + @Test + @UnitTestMethod(target = MaterialsProducerPropertyDefinitionInitialization.Builder.class, name = "setMaterialsProducerPropertyId", args = { + MaterialsProducerPropertyId.class }) + public void testSetMaterialsProducerPropertyId() { + MaterialsProducerPropertyDefinitionInitialization.Builder builder = MaterialsProducerPropertyDefinitionInitialization + .builder(); + PropertyDefinition propertyDefinition = PropertyDefinition.builder() + .setDefaultValue(100) + .setPropertyValueMutability(false) + .setType(Integer.class) + .setTimeTrackingPolicy(TimeTrackingPolicy.DO_NOT_TRACK_TIME) + .build(); + MaterialsProducerPropertyId producerPropertyId = TestMaterialsProducerPropertyId.MATERIALS_PRODUCER_PROPERTY_8_INTEGER_IMMUTABLE_NO_TRACK; + + builder.setPropertyDefinition(propertyDefinition).setMaterialsProducerPropertyId(producerPropertyId); + + MaterialsProducerPropertyDefinitionInitialization definitionInitialization = builder.build(); + + assertNotNull(definitionInitialization); + assertEquals(producerPropertyId, definitionInitialization.getMaterialsProducerPropertyId()); + + // precondition: producer property id is null + ContractException contractException = assertThrows(ContractException.class, + () -> MaterialsProducerPropertyDefinitionInitialization + .builder() + .setMaterialsProducerPropertyId(null)); + assertEquals(PropertyError.NULL_PROPERTY_ID, contractException.getErrorType()); + } +} diff --git a/gcm4/src/test/java/plugins/materials/testsupport/AT_MaterialsActionSupport.java b/gcm4/src/test/java/plugins/materials/testsupport/AT_MaterialsActionSupport.java new file mode 100644 index 000000000..e0fe2f6f9 --- /dev/null +++ b/gcm4/src/test/java/plugins/materials/testsupport/AT_MaterialsActionSupport.java @@ -0,0 +1,33 @@ +package plugins.materials.testsupport; + +import java.util.function.Consumer; + +import org.junit.jupiter.api.Test; + +import nucleus.Plugin; +import tools.annotations.UnitTag; +import tools.annotations.UnitTest; +import tools.annotations.UnitTestMethod; + +@UnitTest(target = MaterialsActionSupport.class) +public class AT_MaterialsActionSupport { + + @Test + @UnitTestMethod(name = "testConsumer", args = { long.class, Consumer.class }, tags = { UnitTag.INCOMPLETE }) + public void testTestConsumer() { + // TBD + } + + @Test + @UnitTestMethod(name = "testConsumers", args = { long.class, Plugin.class }, tags = { UnitTag.INCOMPLETE }) + public void testTestConsumers2() { + // TBD + } + + @Test + @UnitTestMethod(name = "testConsumers", args = { long.class, Plugin.class, Consumer.class }, tags = { + UnitTag.INCOMPLETE }) + public void testTestConsumers() { + // TBD + } +} diff --git a/gcm4/src/test/java/plugins/materials/testsupport/AT_TestBatchConstructionInfo.java b/gcm4/src/test/java/plugins/materials/testsupport/AT_TestBatchConstructionInfo.java new file mode 100644 index 000000000..fe6bca39e --- /dev/null +++ b/gcm4/src/test/java/plugins/materials/testsupport/AT_TestBatchConstructionInfo.java @@ -0,0 +1,56 @@ +package plugins.materials.testsupport; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.apache.commons.math3.random.RandomGenerator; +import org.junit.jupiter.api.Test; + +import plugins.materials.support.BatchConstructionInfo; +import plugins.materials.support.MaterialId; +import plugins.materials.support.MaterialsError; +import plugins.materials.support.MaterialsProducerId; +import tools.annotations.UnitTest; +import tools.annotations.UnitTestMethod; +import util.errors.ContractException; +import util.random.RandomGeneratorProvider; + +@UnitTest(target = TestBatchConstructionInfo.class) +public class AT_TestBatchConstructionInfo { + + @Test + @UnitTestMethod(name = "getBatchConstructionInfo", args = { MaterialsProducerId.class, MaterialId.class, + double.class, RandomGenerator.class }) + public void testGetBatchConstructionInfo() { + MaterialsProducerId materialsProducerId = TestMaterialsProducerId.MATERIALS_PRODUCER_1; + MaterialId materialId = TestMaterialId.MATERIAL_1; + double amount = 25.0; + RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(2531244935109186076L); + + BatchConstructionInfo batchConstructionInfo = TestBatchConstructionInfo + .getBatchConstructionInfo(materialsProducerId, materialId, amount, randomGenerator); + + assertNotNull(batchConstructionInfo); + + // precondition: null material id + ContractException contractException = assertThrows(ContractException.class, () -> TestBatchConstructionInfo + .getBatchConstructionInfo(materialsProducerId, null, amount, randomGenerator)); + assertEquals(MaterialsError.NULL_MATERIAL_ID, contractException.getErrorType()); + + // precondition: null material producer id + contractException = assertThrows(ContractException.class, () -> TestBatchConstructionInfo + .getBatchConstructionInfo(null, materialId, amount, randomGenerator)); + assertEquals(MaterialsError.NULL_MATERIALS_PRODUCER_ID, contractException.getErrorType()); + + // precondition: negative amount + contractException = assertThrows(ContractException.class, () -> TestBatchConstructionInfo + .getBatchConstructionInfo(materialsProducerId, materialId, -100.0, randomGenerator)); + assertEquals(MaterialsError.NEGATIVE_MATERIAL_AMOUNT, contractException.getErrorType()); + + // precondition: amount is not finite + contractException = assertThrows(ContractException.class, () -> TestBatchConstructionInfo + .getBatchConstructionInfo(materialsProducerId, materialId, Double.POSITIVE_INFINITY, randomGenerator)); + assertEquals(MaterialsError.NON_FINITE_MATERIAL_AMOUNT, contractException.getErrorType()); + } +} diff --git a/gcm4/src/test/java/plugins/materials/testsupport/AT_TestMaterialsProducerPropertyId.java b/gcm4/src/test/java/plugins/materials/testsupport/AT_TestMaterialsProducerPropertyId.java index 775090272..e968fc67a 100644 --- a/gcm4/src/test/java/plugins/materials/testsupport/AT_TestMaterialsProducerPropertyId.java +++ b/gcm4/src/test/java/plugins/materials/testsupport/AT_TestMaterialsProducerPropertyId.java @@ -5,6 +5,11 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + import org.apache.commons.math3.random.RandomGenerator; import org.junit.jupiter.api.Test; @@ -87,4 +92,48 @@ public void testGetRandomMutableMaterialsProducerPropertyId() { public void testSize() { assertEquals(TestMaterialsProducerPropertyId.values().length, TestMaterialsProducerPropertyId.size()); } + + @Test + @UnitTestMethod(name = "getPropertiesWithDefaultValues", args = {}) + public void testGetPropertesWithDefaultValues() { + List expectedValues = new ArrayList<>(); + + for (TestMaterialsProducerPropertyId id : TestMaterialsProducerPropertyId.values()) { + if (id.getPropertyDefinition().getDefaultValue().isPresent()) { + expectedValues.add(id); + } + } + + List actualValues = TestMaterialsProducerPropertyId.getPropertiesWithDefaultValues(); + + assertNotNull(actualValues); + assertEquals(expectedValues.size(), actualValues.size()); + Set setOfExpectedValues = new LinkedHashSet<>(expectedValues); + Set setOfActualValues = new LinkedHashSet<>(actualValues); + assertEquals(setOfExpectedValues, setOfActualValues); + assertEquals(expectedValues.size(), setOfExpectedValues.size()); + assertEquals(actualValues.size(), setOfActualValues.size()); + } + + @Test + @UnitTestMethod(name = "getPropertiesWithoutDefaultValues", args = {}) + public void testGetPropertesWithoutDefaultValues() { + List expectedValues = new ArrayList<>(); + + for (TestMaterialsProducerPropertyId id : TestMaterialsProducerPropertyId.values()) { + if (id.getPropertyDefinition().getDefaultValue().isEmpty()) { + expectedValues.add(id); + } + } + + List actualValues = TestMaterialsProducerPropertyId.getPropertiesWithoutDefaultValues(); + + assertNotNull(actualValues); + assertEquals(expectedValues.size(), actualValues.size()); + Set setOfExpectedValues = new LinkedHashSet<>(expectedValues); + Set setOfActualValues = new LinkedHashSet<>(actualValues); + assertEquals(setOfExpectedValues, setOfActualValues); + assertEquals(expectedValues.size(), setOfExpectedValues.size()); + assertEquals(actualValues.size(), setOfActualValues.size()); + } } diff --git a/gcm4/src/test/java/plugins/regions/support/AT_RegionPropertyDefinitionInitialization.java b/gcm4/src/test/java/plugins/regions/support/AT_RegionPropertyDefinitionInitialization.java index 932044209..06f96be75 100644 --- a/gcm4/src/test/java/plugins/regions/support/AT_RegionPropertyDefinitionInitialization.java +++ b/gcm4/src/test/java/plugins/regions/support/AT_RegionPropertyDefinitionInitialization.java @@ -60,7 +60,7 @@ public void testGetPropertyValues() { int value = randomGenerator.nextInt(100); RegionId regionId = new SimpleRegionId(i * 2 + 5); builder.addPropertyValue(regionId, value); - expectedValues.add(new Pair(regionId, value)); + expectedValues.add(new Pair<>(regionId, value)); } RegionPropertyDefinitionInitialization propertyDefinitionInitialization = builder.build(); @@ -174,7 +174,7 @@ public void testAddPropertyValue() { int value = randomGenerator.nextInt(100); RegionId regionId = new SimpleRegionId(i * 2 + 5); builder.addPropertyValue(regionId, value); - expectedValues.add(new Pair(regionId, value)); + expectedValues.add(new Pair<>(regionId, value)); } RegionPropertyDefinitionInitialization propertyDefinitionInitialization = builder.build();