|
| 1 | +/** |
| 2 | + * Unit tests for the OperationType reported by operations. |
| 3 | + * |
| 4 | + * @license BSD-3-Clause |
| 5 | + */ |
| 6 | + |
| 7 | +package org.kigalisim.lang.operation; |
| 8 | + |
| 9 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 10 | + |
| 11 | +import java.math.BigDecimal; |
| 12 | +import org.junit.jupiter.api.Test; |
| 13 | +import org.kigalisim.engine.number.EngineNumber; |
| 14 | + |
| 15 | +/** |
| 16 | + * Tests for the OperationType reported by operations. |
| 17 | + */ |
| 18 | +public class OperationTypeTest { |
| 19 | + |
| 20 | + private final Operation valueOperation = new PreCalculatedOperation( |
| 21 | + new EngineNumber(BigDecimal.ONE, "units") |
| 22 | + ); |
| 23 | + |
| 24 | + /** |
| 25 | + * Test that a Weibull retire operation reports RETIRE_WEIBULL. |
| 26 | + */ |
| 27 | + @Test |
| 28 | + public void testRetireWeibullType() { |
| 29 | + Operation operation = new RetireWeibullOperation(BigDecimal.TEN, false, false); |
| 30 | + assertEquals(OperationType.RETIRE_WEIBULL, operation.getOperationType()); |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * Test that an exact retire operation reports RETIRE_EXACT. |
| 35 | + */ |
| 36 | + @Test |
| 37 | + public void testRetireExactType() { |
| 38 | + Operation operation = new RetireExactOperation(valueOperation, 5, false, false); |
| 39 | + assertEquals(OperationType.RETIRE_EXACT, operation.getOperationType()); |
| 40 | + } |
| 41 | + |
| 42 | + /** |
| 43 | + * Test that a set operation reports SET. |
| 44 | + */ |
| 45 | + @Test |
| 46 | + public void testSetType() { |
| 47 | + Operation operation = new SetOperation("priorEquipment", valueOperation); |
| 48 | + assertEquals(OperationType.SET, operation.getOperationType()); |
| 49 | + } |
| 50 | + |
| 51 | + /** |
| 52 | + * Test that a change operation reports CHANGE. |
| 53 | + */ |
| 54 | + @Test |
| 55 | + public void testChangeType() { |
| 56 | + Operation operation = new ChangeOperation("priorEquipment", valueOperation); |
| 57 | + assertEquals(OperationType.CHANGE, operation.getOperationType()); |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * Test that operations without a specific type report OTHER. |
| 62 | + */ |
| 63 | + @Test |
| 64 | + public void testDefaultType() { |
| 65 | + assertEquals(OperationType.OTHER, valueOperation.getOperationType()); |
| 66 | + } |
| 67 | +} |
0 commit comments