• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CyclopsMC / IntegratedDynamics / 20210191346

14 Dec 2025 03:32PM UTC coverage: 19.514% (-33.5%) from 53.061%
20210191346

push

github

rubensworks
Remove deprecations

663 of 8728 branches covered (7.6%)

Branch coverage included in aggregate %.

6786 of 29445 relevant lines covered (23.05%)

1.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/org/cyclops/integrateddynamics/gametest/integration/TestIngredientsOperators.java
1
package org.cyclops.integrateddynamics.gametest.integration;
2

3
import com.google.common.collect.Lists;
4
import com.google.common.collect.Maps;
5
import net.minecraft.world.item.Item;
6
import net.minecraft.world.item.ItemStack;
7
import net.minecraft.world.item.Items;
8
import net.minecraft.world.level.block.Blocks;
9
import net.minecraft.world.level.material.Fluids;
10
import net.neoforged.neoforge.fluids.FluidStack;
11
import org.cyclops.commoncapabilities.api.ingredient.IMixedIngredients;
12
import org.cyclops.commoncapabilities.api.ingredient.IngredientComponent;
13
import org.cyclops.commoncapabilities.api.ingredient.MixedIngredients;
14
import org.cyclops.integrateddynamics.api.evaluate.EvaluationException;
15
import org.cyclops.integrateddynamics.api.evaluate.variable.IValue;
16
import org.cyclops.integrateddynamics.api.evaluate.variable.IVariable;
17
import org.cyclops.integrateddynamics.core.evaluate.operator.Operators;
18
import org.cyclops.integrateddynamics.core.evaluate.variable.*;
19
import org.cyclops.integrateddynamics.core.test.IntegrationBefore;
20
import org.cyclops.integrateddynamics.core.test.IntegrationTest;
21
import org.cyclops.integrateddynamics.core.test.TestHelpers;
22

23
import java.util.Collections;
24
import java.util.List;
25
import java.util.Map;
26
import java.util.function.Predicate;
27

28
/**
29
 * Test the different ingredients operators.
30
 * @author rubensworks
31
 */
32
public class TestIngredientsOperators {
×
33

34
    private static final DummyValueType DUMMY_TYPE = DummyValueType.TYPE;
×
35
    private static final DummyVariable<DummyValueType.DummyValue> DUMMY_VARIABLE =
×
36
            new DummyVariable<DummyValueType.DummyValue>(DUMMY_TYPE, DummyValueType.DummyValue.of());
×
37

38
    private DummyVariable<ValueTypeInteger.ValueInteger> i0;
39
    private DummyVariable<ValueTypeInteger.ValueInteger> i1;
40
    private DummyVariable<ValueTypeInteger.ValueInteger> i2;
41
    private DummyVariable<ValueTypeInteger.ValueInteger> i3;
42

43
    private DummyVariableIngredients iEmpty;
44
    private DummyVariableIngredients iItems;
45
    private DummyVariable<ValueTypeList.ValueList> lItems;
46
    private DummyVariableIngredients iFluids;
47
    private DummyVariable<ValueTypeList.ValueList> lFluids;
48
    private DummyVariableIngredients iEnergies;
49
    private DummyVariable<ValueTypeList.ValueList> lEnergies;
50
    private IMixedIngredients inputIngredients;
51
    private DummyVariableIngredients iMix;
52

53
    private DummyVariable<ValueObjectTypeItemStack.ValueItemStack> iItem;
54
    private Predicate<ValueObjectTypeItemStack.ValueItemStack> pItemRaw;
55
    private DummyVariable<ValueTypeOperator.ValueOperator> pItem;
56

57
    private DummyVariable<ValueObjectTypeFluidStack.ValueFluidStack> iFluid;
58
    private Predicate<ValueObjectTypeFluidStack.ValueFluidStack> pFluidRaw;
59
    private DummyVariable<ValueTypeOperator.ValueOperator> pFluid;
60

61
    private DummyVariable<ValueTypeLong.ValueLong> iEnergy;
62
    private Predicate<ValueTypeInteger.ValueInteger> pEnergyRaw;
63
    private DummyVariable<ValueTypeOperator.ValueOperator> pEnergy;
64

65
    @IntegrationBefore
66
    public void before() {
67
        i0 = new DummyVariable<>(ValueTypes.INTEGER, ValueTypeInteger.ValueInteger.of(0));
×
68
        i1 = new DummyVariable<>(ValueTypes.INTEGER, ValueTypeInteger.ValueInteger.of(1));
×
69
        i2 = new DummyVariable<>(ValueTypes.INTEGER, ValueTypeInteger.ValueInteger.of(2));
×
70
        i3 = new DummyVariable<>(ValueTypes.INTEGER, ValueTypeInteger.ValueInteger.of(3));
×
71

72
        iEmpty = new DummyVariableIngredients(ValueObjectTypeIngredients.ValueIngredients.of(
×
73
                new MixedIngredients(Maps.newIdentityHashMap())));
×
74

75
        iItems = new DummyVariableIngredients(ValueObjectTypeIngredients.ValueIngredients.of(
×
76
                MixedIngredients.ofInstances(IngredientComponent.ITEMSTACK, Lists.newArrayList(
×
77
                        ItemStack.EMPTY, new ItemStack(Items.OAK_BOAT), new ItemStack(Blocks.STONE), ItemStack.EMPTY)
78
                )));
79
        lItems = new DummyVariable<>(ValueTypes.LIST, ValueTypeList.ValueList.ofAll(
×
80
                ValueObjectTypeItemStack.ValueItemStack.of(ItemStack.EMPTY),
×
81
                ValueObjectTypeItemStack.ValueItemStack.of(new ItemStack(Items.OAK_BOAT)),
×
82
                ValueObjectTypeItemStack.ValueItemStack.of(new ItemStack(Blocks.STONE)),
×
83
                ValueObjectTypeItemStack.ValueItemStack.of(ItemStack.EMPTY)
×
84
        ));
85

86
        iFluids = new DummyVariableIngredients(ValueObjectTypeIngredients.ValueIngredients.of(
×
87
                MixedIngredients.ofInstances(IngredientComponent.FLUIDSTACK, Lists.newArrayList(
×
88
                        new FluidStack(Fluids.LAVA, 1000), new FluidStack(Fluids.WATER, 125))
89
                )));
90
        lFluids = new DummyVariable<>(ValueTypes.LIST, ValueTypeList.ValueList.ofAll(
×
91
                ValueObjectTypeFluidStack.ValueFluidStack.of(new FluidStack(Fluids.LAVA, 1000)),
×
92
                ValueObjectTypeFluidStack.ValueFluidStack.of(new FluidStack(Fluids.WATER, 125))
×
93
        ));
94

95
        iEnergies = new DummyVariableIngredients(ValueObjectTypeIngredients.ValueIngredients.of(
×
96
                MixedIngredients.ofInstances(IngredientComponent.ENERGY, Lists.newArrayList(
×
97
                        666L, 777L, 0L)
×
98
                )));
99
        lEnergies = new DummyVariable<>(ValueTypes.LIST, ValueTypeList.ValueList.ofAll(
×
100
                ValueTypeLong.ValueLong.of(666L),
×
101
                ValueTypeLong.ValueLong.of(777L),
×
102
                ValueTypeLong.ValueLong.of(0L)
×
103
        ));
104

105
        Map<IngredientComponent<?, ?>, List<?>> ingredients = Maps.newIdentityHashMap();
×
106
        ingredients.put(IngredientComponent.ENERGY, Lists.newArrayList(777L));
×
107
        ingredients.put(IngredientComponent.FLUIDSTACK, Lists.newArrayList(new FluidStack(Fluids.WATER, 125)));
×
108
        ingredients.put(IngredientComponent.ITEMSTACK, Lists.newArrayList(new ItemStack(Items.OAK_BOAT), new ItemStack(Item.byBlock(Blocks.STONE))));
×
109
        inputIngredients = new MixedIngredients(ingredients);
×
110
        iMix = new DummyVariableIngredients(ValueObjectTypeIngredients.ValueIngredients.of(inputIngredients));
×
111

112
        iItem = new DummyVariable<>(ValueTypes.OBJECT_ITEMSTACK, ValueObjectTypeItemStack.ValueItemStack.of(new ItemStack(Items.APPLE)));
×
113
        iFluid = new DummyVariable<>(ValueTypes.OBJECT_FLUIDSTACK, ValueObjectTypeFluidStack.ValueFluidStack.of(new FluidStack(Fluids.WATER, 123)));
×
114
        iEnergy = new DummyVariable<>(ValueTypes.LONG, ValueTypeLong.ValueLong.of(123L));
×
115
    }
×
116

117
    /**
118
     * ----------------------------------- ITEMS -----------------------------------
119
     */
120

121
    @IntegrationTest
122
    public void testItems() throws EvaluationException {
123
        IValue res1 = Operators.INGREDIENTS_ITEMS.evaluate(new IVariable[]{iMix});
×
124
        Asserts.check(res1 instanceof ValueTypeList.ValueList, "result is a list");
×
125
        TestHelpers.assertEqual(((ValueTypeList.ValueList) res1).getRawValue().getLength(), 2, "items(mix, 0).size = 2");
×
126
        TestHelpers.assertEqual(((ValueTypeList.ValueList<ValueObjectTypeItemStack, ValueObjectTypeItemStack.ValueItemStack>) res1)
×
127
                .getRawValue().get(0).getRawValue().getItem(), Items.OAK_BOAT, "items(mix, 0) = boat");
×
128
        TestHelpers.assertEqual(((ValueTypeList.ValueList<ValueObjectTypeItemStack, ValueObjectTypeItemStack.ValueItemStack>) res1)
×
129
                .getRawValue().get(1).getRawValue().getItem(), Item.byBlock(Blocks.STONE), "items(mix, 0) = boat");
×
130
    }
×
131

132
    @IntegrationTest(expected = EvaluationException.class)
133
    public void testItemsSizeLarge() throws EvaluationException {
134
        Operators.INGREDIENTS_ITEMS.evaluate(new IVariable[]{iMix, i0});
×
135
    }
×
136

137
    @IntegrationTest(expected = EvaluationException.class)
138
    public void testItemsSizeSmall() throws EvaluationException {
139
        Operators.INGREDIENTS_ITEMS.evaluate(new IVariable[]{});
×
140
    }
×
141

142
    @IntegrationTest(expected = EvaluationException.class)
143
    public void testItemsSize() throws EvaluationException {
144
        Operators.INGREDIENTS_ITEMS.evaluate(new IVariable[]{DUMMY_VARIABLE});
×
145
    }
×
146

147
    /**
148
     * ----------------------------------- FLUIDS -----------------------------------
149
     */
150

151
    @IntegrationTest
152
    public void testFluids() throws EvaluationException {
153
        IValue res1 = Operators.INGREDIENTS_FLUIDS.evaluate(new IVariable[]{iFluids});
×
154
        Asserts.check(res1 instanceof ValueTypeList.ValueList, "result is a list");
×
155
        TestHelpers.assertEqual(((ValueTypeList.ValueList) res1).getRawValue().getLength(), 2, "fluids(fluids, 0).size = 2");
×
156
        TestHelpers.assertEqual(res1,
×
157
                ValueTypeList.ValueList.ofList(ValueTypes.OBJECT_FLUIDSTACK, Lists.newArrayList(
×
158
                        ValueObjectTypeFluidStack.ValueFluidStack.of(new FluidStack(Fluids.LAVA, 1000)),
×
159
                        ValueObjectTypeFluidStack.ValueFluidStack.of(new FluidStack(Fluids.WATER, 125))
×
160
                )), "fluids(fluids) = lava, water");
161
    }
×
162

163
    @IntegrationTest(expected = EvaluationException.class)
164
    public void testFluidsSizeLarge() throws EvaluationException {
165
        Operators.INGREDIENTS_FLUIDS.evaluate(new IVariable[]{iMix, i0});
×
166
    }
×
167

168
    @IntegrationTest(expected = EvaluationException.class)
169
    public void testFluidsSizeSmall() throws EvaluationException {
170
        Operators.INGREDIENTS_FLUIDS.evaluate(new IVariable[]{});
×
171
    }
×
172

173
    @IntegrationTest(expected = EvaluationException.class)
174
    public void testFluidsSize() throws EvaluationException {
175
        Operators.INGREDIENTS_FLUIDS.evaluate(new IVariable[]{DUMMY_VARIABLE});
×
176
    }
×
177

178
    /**
179
     * ----------------------------------- ENERGIES -----------------------------------
180
     */
181

182
    @IntegrationTest
183
    public void testEnergies() throws EvaluationException {
184
        IValue res1 = Operators.INGREDIENTS_ENERGIES.evaluate(new IVariable[]{iEnergies});
×
185
        Asserts.check(res1 instanceof ValueTypeList.ValueList, "result is a list");
×
186
        TestHelpers.assertEqual(((ValueTypeList.ValueList) res1).getRawValue().getLength(), 3, "energys(energys, 0).size = 1");
×
187
        TestHelpers.assertEqual(((ValueTypeList.ValueList<ValueTypeLong, ValueTypeLong.ValueLong>) res1)
×
188
                .getRawValue().get(0).getRawValue(), 666L, "energies(energies, 0) = 666");
×
189
        TestHelpers.assertEqual(((ValueTypeList.ValueList<ValueTypeLong, ValueTypeLong.ValueLong>) res1)
×
190
                .getRawValue().get(1).getRawValue(), 777L, "energies(energies, 0) = 777");
×
191
        TestHelpers.assertEqual(((ValueTypeList.ValueList<ValueTypeLong, ValueTypeLong.ValueLong>) res1)
×
192
                .getRawValue().get(2).getRawValue(), 0L, "energies(energies, 0) = 0");
×
193
    }
×
194

195
    @IntegrationTest(expected = EvaluationException.class)
196
    public void testEnergiesSizeLarge() throws EvaluationException {
197
        Operators.INGREDIENTS_ENERGIES.evaluate(new IVariable[]{iMix, i0});
×
198
    }
×
199

200
    @IntegrationTest(expected = EvaluationException.class)
201
    public void testEnergiesSizeSmall() throws EvaluationException {
202
        Operators.INGREDIENTS_ENERGIES.evaluate(new IVariable[]{});
×
203
    }
×
204

205
    @IntegrationTest(expected = EvaluationException.class)
206
    public void testEnergiesSize() throws EvaluationException {
207
        Operators.INGREDIENTS_ENERGIES.evaluate(new IVariable[]{DUMMY_VARIABLE});
×
208
    }
×
209

210
    /**
211
     * ----------------------------------- WITH_ITEM -----------------------------------
212
     */
213

214
    @IntegrationTest
215
    public void testWithItem() throws EvaluationException {
216
        IValue res1 = Operators.INGREDIENTS_WITH_ITEM.evaluate(new IVariable[]{iMix, i0, iItem});
×
217
        Asserts.check(res1 instanceof ValueObjectTypeIngredients.ValueIngredients, "result is an ingredient");
×
218
        IMixedIngredients outputIngredients1 = ((ValueObjectTypeIngredients.ValueIngredients) res1).getRawValue().get();
×
219
        List<ItemStack> outputList1 = outputIngredients1.getInstances(IngredientComponent.ITEMSTACK);
×
220
        TestHelpers.assertEqual(outputList1.size(), 2, "with_items(mix, 0, items)[0]size = 2");
×
221
        TestHelpers.assertEqual(outputList1.get(0).getItem(), Items.APPLE,
×
222
                "with_items(mix, 0, items)[0] = items[0]");
223
        TestHelpers.assertEqual(outputList1.get(1).getItem(), Item.byBlock(Blocks.STONE),
×
224
                "with_items(mix, 0, items)[1] = items[1]");
225

226
        TestHelpers.assertEqual(outputIngredients1.getInstances(IngredientComponent.ITEMSTACK).size(), inputIngredients.getInstances(IngredientComponent.ITEMSTACK).size(), "Items size remains the same");
×
227
        TestHelpers.assertNonEqual(outputIngredients1.getInstances(IngredientComponent.ITEMSTACK).get(0), inputIngredients.getInstances(IngredientComponent.ITEMSTACK).get(0), "Items 0 changes");
×
228
        TestHelpers.assertEqual(outputIngredients1.getInstances(IngredientComponent.ITEMSTACK).get(1), inputIngredients.getInstances(IngredientComponent.ITEMSTACK).get(1), "Items 1 remains the same");
×
229
        TestHelpers.assertEqual(outputIngredients1.getInstances(IngredientComponent.FLUIDSTACK), inputIngredients.getInstances(IngredientComponent.FLUIDSTACK), "Fluid remains the same");
×
230
        TestHelpers.assertEqual(outputIngredients1.getInstances(IngredientComponent.ENERGY), inputIngredients.getInstances(IngredientComponent.ENERGY), "Energy remains the same");
×
231

232

233
        IValue res2 = Operators.INGREDIENTS_WITH_ITEM.evaluate(new IVariable[]{iMix, i2, iItem});
×
234
        IMixedIngredients outputIngredients2 = ((ValueObjectTypeIngredients.ValueIngredients) res2).getRawValue().get();
×
235
        List<ItemStack> outputList2 = outputIngredients2.getInstances(IngredientComponent.ITEMSTACK);
×
236
        TestHelpers.assertEqual(outputList2.size(), 3, "with_items(mix, 2, items)[0]size = 3");
×
237
        TestHelpers.assertEqual(outputList2.get(0).getItem(), Items.OAK_BOAT,
×
238
                "with_items(mix, 2, items)[0] = items[0]");
239
        TestHelpers.assertEqual(outputList2.get(1).getItem(), Item.byBlock(Blocks.STONE),
×
240
                "with_items(mix, 2, items)[1] = items[1]");
241
        TestHelpers.assertEqual(outputList2.get(2).getItem(), Items.APPLE,
×
242
                "with_items(mix, 2, items)[2] = items[2]");
243

244
        TestHelpers.assertNonEqual(outputIngredients2.getInstances(IngredientComponent.ITEMSTACK).size(), inputIngredients.getInstances(IngredientComponent.ITEMSTACK).size(), "Items size changes");
×
245
        TestHelpers.assertEqual(outputIngredients2.getInstances(IngredientComponent.ITEMSTACK).get(0), inputIngredients.getInstances(IngredientComponent.ITEMSTACK).get(0), "Items 0 remains the same");
×
246
        TestHelpers.assertEqual(outputIngredients2.getInstances(IngredientComponent.ITEMSTACK).get(1), inputIngredients.getInstances(IngredientComponent.ITEMSTACK).get(1), "Items 1 remains the same");
×
247
        TestHelpers.assertNonEqual(outputIngredients2.getInstances(IngredientComponent.ITEMSTACK).get(2), Collections.emptyList(), "Items 3 is not empty");
×
248
        TestHelpers.assertEqual(outputIngredients2.getInstances(IngredientComponent.FLUIDSTACK), inputIngredients.getInstances(IngredientComponent.FLUIDSTACK), "Fluid remains the same");
×
249
        TestHelpers.assertEqual(outputIngredients2.getInstances(IngredientComponent.ENERGY), inputIngredients.getInstances(IngredientComponent.ENERGY), "Energy remains the same");
×
250
    }
×
251

252
    @IntegrationTest(expected = EvaluationException.class)
253
    public void testWithItemSizeLarge() throws EvaluationException {
254
        Operators.INGREDIENTS_WITH_ITEM.evaluate(new IVariable[]{iMix, i0, iItem});
×
255
    }
×
256

257
    @IntegrationTest(expected = EvaluationException.class)
258
    public void testWithItemSizeSmall() throws EvaluationException {
259
        Operators.INGREDIENTS_WITH_ITEM.evaluate(new IVariable[]{iMix, i0});
×
260
    }
×
261

262
    @IntegrationTest(expected = EvaluationException.class)
263
    public void testWithItemSize() throws EvaluationException {
264
        Operators.INGREDIENTS_WITH_ITEM.evaluate(new IVariable[]{DUMMY_VARIABLE, DUMMY_VARIABLE, DUMMY_VARIABLE});
×
265
    }
×
266

267
    /**
268
     * ----------------------------------- WITH_FLUID -----------------------------------
269
     */
270

271
    @IntegrationTest
272
    public void testWithFluid() throws EvaluationException {
273
        IValue res1 = Operators.INGREDIENTS_WITH_FLUID.evaluate(new IVariable[]{iMix, i0, iFluid});
×
274
        Asserts.check(res1 instanceof ValueObjectTypeIngredients.ValueIngredients, "result is an ingredient");
×
275
        IMixedIngredients outputIngredients1 = ((ValueObjectTypeIngredients.ValueIngredients) res1).getRawValue().get();
×
276
        List<FluidStack> outputList1 = outputIngredients1.getInstances(IngredientComponent.FLUIDSTACK);
×
277
        TestHelpers.assertEqual(outputList1.size(), 1, "with_fluids(mix, 0, fluids)[0]size = 1");
×
278
        TestHelpers.assertEqual(FluidStack.matches(outputList1.get(0), new FluidStack(Fluids.WATER, 123)), true,
×
279
                "with_fluids(mix, 0, fluids)[0] = fluids[0]");
280

281
        TestHelpers.assertEqual(outputIngredients1.getInstances(IngredientComponent.FLUIDSTACK).size(), inputIngredients.getInstances(IngredientComponent.FLUIDSTACK).size(), "Fluids size remains the same");
×
282
        TestHelpers.assertNonEqual(ValueObjectTypeFluidStack.ValueFluidStack.of(outputIngredients1.getInstances(IngredientComponent.FLUIDSTACK).get(0)), ValueObjectTypeFluidStack.ValueFluidStack.of(inputIngredients.getInstances(IngredientComponent.FLUIDSTACK).get(0)), "Fluids 0 changes");
×
283
        TestHelpers.assertEqual(outputIngredients1.getInstances(IngredientComponent.ITEMSTACK), inputIngredients.getInstances(IngredientComponent.ITEMSTACK), "Items remains the same");
×
284
        TestHelpers.assertEqual(outputIngredients1.getInstances(IngredientComponent.ENERGY), inputIngredients.getInstances(IngredientComponent.ENERGY), "Energy remains the same");
×
285

286

287
        IValue res2 = Operators.INGREDIENTS_WITH_FLUID.evaluate(new IVariable[]{iMix, i2, iFluid});
×
288
        IMixedIngredients outputIngredients2 = ((ValueObjectTypeIngredients.ValueIngredients) res2).getRawValue().get();
×
289
        List<FluidStack> outputList2 = outputIngredients2.getInstances(IngredientComponent.FLUIDSTACK);
×
290
        TestHelpers.assertEqual(outputList2.size(), 3, "with_fluids(mix, 3, fluids)[0]size = 2");
×
291
        TestHelpers.assertEqual(FluidStack.matches(outputList2.get(0), new FluidStack(Fluids.WATER, 125)), true,
×
292
                "with_fluids(mix, 2, fluids)[0] = fluids[0]");
293
        TestHelpers.assertEqual(FluidStack.matches(outputList2.get(1), FluidStack.EMPTY), true,
×
294
                "with_fluids(mix, 2, fluids)[1] = fluids[1]");
295
        TestHelpers.assertEqual(FluidStack.matches(outputList2.get(2), new FluidStack(Fluids.WATER, 123)), true,
×
296
                "with_fluids(mix, 2, fluids)[2] = fluids[2]");
297

298
        TestHelpers.assertNonEqual(outputIngredients2.getInstances(IngredientComponent.FLUIDSTACK).size(), inputIngredients.getInstances(IngredientComponent.FLUIDSTACK).size(), "Fluids size changes");
×
299
        TestHelpers.assertNonEqual(outputIngredients2.getInstances(IngredientComponent.FLUIDSTACK).get(2), Collections.emptyList(), "Fluids 3 is not empty");
×
300
        TestHelpers.assertEqual(outputIngredients2.getInstances(IngredientComponent.ITEMSTACK), inputIngredients.getInstances(IngredientComponent.ITEMSTACK), "Items remains the same");
×
301
        TestHelpers.assertEqual(outputIngredients2.getInstances(IngredientComponent.ENERGY), inputIngredients.getInstances(IngredientComponent.ENERGY), "Energy remains the same");
×
302
    }
×
303

304
    @IntegrationTest(expected = EvaluationException.class)
305
    public void testWithFluidSizeLarge() throws EvaluationException {
306
        Operators.INGREDIENTS_WITH_FLUID.evaluate(new IVariable[]{iMix, i0, iFluid});
×
307
    }
×
308

309
    @IntegrationTest(expected = EvaluationException.class)
310
    public void testWithFluidSizeSmall() throws EvaluationException {
311
        Operators.INGREDIENTS_WITH_FLUID.evaluate(new IVariable[]{iMix, i0});
×
312
    }
×
313

314
    @IntegrationTest(expected = EvaluationException.class)
315
    public void testWithFluidSize() throws EvaluationException {
316
        Operators.INGREDIENTS_WITH_FLUID.evaluate(new IVariable[]{DUMMY_VARIABLE, DUMMY_VARIABLE, DUMMY_VARIABLE});
×
317
    }
×
318

319
    /**
320
     * ----------------------------------- WITH_ENERGY -----------------------------------
321
     */
322

323
    @IntegrationTest
324
    public void testWithEnergy() throws EvaluationException {
325
        IValue res1 = Operators.INGREDIENTS_WITH_ENERGY.evaluate(new IVariable[]{iMix, i0, iEnergy});
×
326
        Asserts.check(res1 instanceof ValueObjectTypeIngredients.ValueIngredients, "result is an ingredient");
×
327
        IMixedIngredients outputIngredients1 = ((ValueObjectTypeIngredients.ValueIngredients) res1).getRawValue().get();
×
328
        List<Long> outputList1 = outputIngredients1.getInstances(IngredientComponent.ENERGY);
×
329
        TestHelpers.assertEqual(outputList1.size(), 1, "with_energy(mix, 0, energy)[0]size = 2");
×
330
        TestHelpers.assertEqual(outputList1.get(0), 123L, "with_energy(mix, 0, energy)[0][0] = energy[0]");
×
331

332
        TestHelpers.assertEqual(outputIngredients1.getInstances(IngredientComponent.ENERGY).size(), inputIngredients.getInstances(IngredientComponent.ENERGY).size(), "Energies size remains the same");
×
333
        TestHelpers.assertNonEqual(outputIngredients1.getInstances(IngredientComponent.ENERGY).get(0), inputIngredients.getInstances(IngredientComponent.ENERGY).get(0), "Energies 0 changes");
×
334
        TestHelpers.assertEqual(outputIngredients1.getInstances(IngredientComponent.ITEMSTACK), inputIngredients.getInstances(IngredientComponent.ITEMSTACK), "Items remains the same");
×
335
        TestHelpers.assertEqual(outputIngredients1.getInstances(IngredientComponent.FLUIDSTACK), inputIngredients.getInstances(IngredientComponent.FLUIDSTACK), "Fluids remains the same");
×
336

337

338
        IValue res2 = Operators.INGREDIENTS_WITH_ENERGY.evaluate(new IVariable[]{iMix, i2, iEnergy});
×
339
        IMixedIngredients outputIngredients2 = ((ValueObjectTypeIngredients.ValueIngredients) res2).getRawValue().get();
×
340
        List<Long> outputList2 = outputIngredients2.getInstances(IngredientComponent.ENERGY);
×
341
        TestHelpers.assertEqual(outputList2.size(), 3, "with_energy(mix, 2, energy)[0]size = 3");
×
342
        TestHelpers.assertEqual(outputList2.get(0), 777L, "with_energy(mix, 2, energy)[3][0] = energy[0]");
×
343
        TestHelpers.assertEqual(outputList2.get(1), 0L, "with_energy(mix, 2, energy)[3][0] = energy[0]");
×
344
        TestHelpers.assertEqual(outputList2.get(2), 123L, "with_energy(mix, 2, energy)[3][0] = energy[0]");
×
345

346
        TestHelpers.assertNonEqual(outputIngredients2.getInstances(IngredientComponent.ENERGY).size(), inputIngredients.getInstances(IngredientComponent.ENERGY).size(), "Energies size changes");
×
347
        TestHelpers.assertNonEqual(outputIngredients2.getInstances(IngredientComponent.ENERGY).get(2), Collections.emptyList(), "Energies 3 is not empty");
×
348
        TestHelpers.assertEqual(outputIngredients2.getInstances(IngredientComponent.ITEMSTACK), inputIngredients.getInstances(IngredientComponent.ITEMSTACK), "Items remains the same");
×
349
        TestHelpers.assertEqual(outputIngredients2.getInstances(IngredientComponent.FLUIDSTACK), inputIngredients.getInstances(IngredientComponent.FLUIDSTACK), "Fluids remains the same");
×
350
    }
×
351

352
    @IntegrationTest(expected = EvaluationException.class)
353
    public void testWithEnergySizeLarge() throws EvaluationException {
354
        Operators.INGREDIENTS_WITH_ENERGY.evaluate(new IVariable[]{iMix, i0, iEnergy});
×
355
    }
×
356

357
    @IntegrationTest(expected = EvaluationException.class)
358
    public void testWithEnergySizeSmall() throws EvaluationException {
359
        Operators.INGREDIENTS_WITH_ENERGY.evaluate(new IVariable[]{iMix, i0});
×
360
    }
×
361

362
    @IntegrationTest(expected = EvaluationException.class)
363
    public void testWithEnergySize() throws EvaluationException {
364
        Operators.INGREDIENTS_WITH_ENERGY.evaluate(new IVariable[]{DUMMY_VARIABLE, DUMMY_VARIABLE, DUMMY_VARIABLE});
×
365
    }
×
366

367
    /**
368
     * ----------------------------------- WITH_ITEMS -----------------------------------
369
     */
370

371
    @IntegrationTest
372
    public void testWithItems() throws EvaluationException {
373
        IValue res1 = Operators.INGREDIENTS_WITH_ITEMS.evaluate(new IVariable[]{iMix, lItems});
×
374
        Asserts.check(res1 instanceof ValueObjectTypeIngredients.ValueIngredients, "result is an ingredient");
×
375
        IMixedIngredients outputIngredients1 = ((ValueObjectTypeIngredients.ValueIngredients) res1).getRawValue().get();
×
376
        List<ItemStack> outputList1 = outputIngredients1.getInstances(IngredientComponent.ITEMSTACK);
×
377
        TestHelpers.assertEqual(outputList1.size(), 4, "with_items(mix, items)[0]size = 4");
×
378
        TestHelpers.assertEqual(outputList1.get(0).getItem(), Items.AIR,
×
379
                "with_items(mix, items)[0] = items[0]");
380
        TestHelpers.assertEqual(outputList1.get(1).getItem(), Items.OAK_BOAT,
×
381
                "with_items(mix, items)[1] = items[1]");
382
        TestHelpers.assertEqual(outputList1.get(2).getItem(), Item.byBlock(Blocks.STONE),
×
383
                "with_items(mix, items)[2] = items[2]");
384
        TestHelpers.assertEqual(outputList1.get(3).getItem(), Items.AIR,
×
385
                "with_items(mix, items)[3] = items[3]");
386

387
        TestHelpers.assertEqual(outputIngredients1.getInstances(IngredientComponent.FLUIDSTACK), inputIngredients.getInstances(IngredientComponent.FLUIDSTACK), "Fluid remains the same");
×
388
        TestHelpers.assertEqual(outputIngredients1.getInstances(IngredientComponent.ENERGY), inputIngredients.getInstances(IngredientComponent.ENERGY), "Energy remains the same");
×
389
    }
×
390

391
    @IntegrationTest(expected = EvaluationException.class)
392
    public void testWithItemsSizeLarge() throws EvaluationException {
393
        Operators.INGREDIENTS_WITH_ITEMS.evaluate(new IVariable[]{iMix, lItems});
×
394
    }
×
395

396
    @IntegrationTest(expected = EvaluationException.class)
397
    public void testWithItemsSizeSmall() throws EvaluationException {
398
        Operators.INGREDIENTS_WITH_ITEMS.evaluate(new IVariable[]{iMix});
×
399
    }
×
400

401
    @IntegrationTest(expected = EvaluationException.class)
402
    public void testWithItemsSize() throws EvaluationException {
403
        Operators.INGREDIENTS_WITH_ITEMS.evaluate(new IVariable[]{DUMMY_VARIABLE, DUMMY_VARIABLE});
×
404
    }
×
405

406
    /**
407
     * ----------------------------------- WITH_FLUIDS -----------------------------------
408
     */
409

410
    @IntegrationTest
411
    public void testWithFluids() throws EvaluationException {
412
        IValue res1 = Operators.INGREDIENTS_WITH_FLUIDS.evaluate(new IVariable[]{iMix, lFluids});
×
413
        Asserts.check(res1 instanceof ValueObjectTypeIngredients.ValueIngredients, "result is an ingredient");
×
414
        IMixedIngredients outputIngredients1 = ((ValueObjectTypeIngredients.ValueIngredients) res1).getRawValue().get();
×
415
        List<FluidStack> outputList1 = outputIngredients1.getInstances(IngredientComponent.FLUIDSTACK);
×
416
        TestHelpers.assertEqual(outputList1.size(), 2, "with_fluids(mix, fluids)[0]size = 2");
×
417
        TestHelpers.assertEqual(FluidStack.matches(outputList1.get(0), new FluidStack(Fluids.LAVA, 1000)), true,
×
418
                "with_fluids(mix, fluids)[0] = fluids[0]");
419
        TestHelpers.assertEqual(FluidStack.matches(outputList1.get(1), new FluidStack(Fluids.WATER, 125)), true,
×
420
                "with_fluids(mix, fluids)[1] = fluids[1]");
421

422
        TestHelpers.assertEqual(outputIngredients1.getInstances(IngredientComponent.ITEMSTACK), inputIngredients.getInstances(IngredientComponent.ITEMSTACK), "Item remains the same");
×
423
        TestHelpers.assertEqual(outputIngredients1.getInstances(IngredientComponent.ENERGY), inputIngredients.getInstances(IngredientComponent.ENERGY), "Energy remains the same");
×
424
    }
×
425

426
    @IntegrationTest(expected = EvaluationException.class)
427
    public void testWithFluidsSizeLarge() throws EvaluationException {
428
        Operators.INGREDIENTS_WITH_FLUIDS.evaluate(new IVariable[]{iMix, lFluids});
×
429
    }
×
430

431
    @IntegrationTest(expected = EvaluationException.class)
432
    public void testWithFluidsSizeSmall() throws EvaluationException {
433
        Operators.INGREDIENTS_WITH_FLUIDS.evaluate(new IVariable[]{iMix});
×
434
    }
×
435

436
    @IntegrationTest(expected = EvaluationException.class)
437
    public void testWithFluidsSize() throws EvaluationException {
438
        Operators.INGREDIENTS_WITH_FLUIDS.evaluate(new IVariable[]{DUMMY_VARIABLE, DUMMY_VARIABLE});
×
439
    }
×
440

441
    /**
442
     * ----------------------------------- WITH_ENERGIES -----------------------------------
443
     */
444

445
    @IntegrationTest
446
    public void testWithEnergies() throws EvaluationException {
447
        IValue res1 = Operators.INGREDIENTS_WITH_ENERGIES.evaluate(new IVariable[]{iMix, lEnergies});
×
448
        Asserts.check(res1 instanceof ValueObjectTypeIngredients.ValueIngredients, "result is an ingredient");
×
449
        IMixedIngredients outputIngredients1 = ((ValueObjectTypeIngredients.ValueIngredients) res1).getRawValue().get();
×
450
        List<Long> outputList1 = outputIngredients1.getInstances(IngredientComponent.ENERGY);
×
451
        TestHelpers.assertEqual(outputList1.size(), 3, "with_energies(mix, energies)[0]size = 3");
×
452
        TestHelpers.assertEqual(outputList1.get(0), 666L,
×
453
                "with_energies(mix, energies)[0] = energies[0]");
454
        TestHelpers.assertEqual(outputList1.get(1), 777L,
×
455
                "with_energies(mix, energies)[1] = energies[1]");
456
        TestHelpers.assertEqual(outputList1.get(2), 0L,
×
457
                "with_energies(mix, energies)[2] = energies[2]");
458

459
        TestHelpers.assertEqual(outputIngredients1.getInstances(IngredientComponent.ITEMSTACK), inputIngredients.getInstances(IngredientComponent.ITEMSTACK), "Item remains the same");
×
460
        TestHelpers.assertEqual(outputIngredients1.getInstances(IngredientComponent.FLUIDSTACK), inputIngredients.getInstances(IngredientComponent.FLUIDSTACK), "Fluid remains the same");
×
461
    }
×
462

463
    @IntegrationTest(expected = EvaluationException.class)
464
    public void testWithEnergiesSizeLarge() throws EvaluationException {
465
        Operators.INGREDIENTS_WITH_ENERGIES.evaluate(new IVariable[]{iMix, lEnergies});
×
466
    }
×
467

468
    @IntegrationTest(expected = EvaluationException.class)
469
    public void testWithEnergiesSizeSmall() throws EvaluationException {
470
        Operators.INGREDIENTS_WITH_ENERGIES.evaluate(new IVariable[]{iMix});
×
471
    }
×
472

473
    @IntegrationTest(expected = EvaluationException.class)
474
    public void testWithEnergiesSize() throws EvaluationException {
475
        Operators.INGREDIENTS_WITH_ENERGIES.evaluate(new IVariable[]{DUMMY_VARIABLE, DUMMY_VARIABLE});
×
476
    }
×
477

478
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc