-
Notifications
You must be signed in to change notification settings - Fork 19
/
TapChangeActionTest.java
73 lines (62 loc) · 2.77 KB
/
TapChangeActionTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
* Copyright (c) 2017, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package eu.itesla_project.modules.contigencies;
import eu.itesla_project.computation.ComputationManager;
import eu.itesla_project.computation.local.LocalComputationManager;
import com.google.common.jimfs.Configuration;
import com.google.common.jimfs.Jimfs;
import eu.itesla_project.contingency.tasks.ModificationTask;
import eu.itesla_project.iidm.network.Network;
import eu.itesla_project.iidm.network.PhaseTapChanger;
import eu.itesla_project.iidm.network.test.PhaseShifterTestCaseFactory;
import eu.itesla_project.modules.contingencies.ActionElementType;
import eu.itesla_project.modules.contingencies.TapChangeAction;
import org.junit.Test;
import java.io.IOException;
import java.nio.file.FileSystem;
import java.nio.file.Path;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
/**
* @author Mathieu Bague <mathieu.bague at rte-france.com>
*/
public class TapChangeActionTest {
@Test
public void testContructors() {
TapChangeAction action = new TapChangeAction("equipmentId", 1);
assertEquals("equipmentId", action.getEquipmentId());
assertEquals(1, action.getTapPosition());
assertNull(action.getAchievmentIndex());
assertNull(action.getImplementationTime());
assertEquals(ActionElementType.TAP_CHANGE, action.getType());
action = new TapChangeAction("equipmentId2", 2, 150, 0);
assertEquals("equipmentId2", action.getEquipmentId());
assertEquals(2, action.getTapPosition());
assertEquals(0, action.getAchievmentIndex());
assertEquals(150, action.getImplementationTime());
}
@Test
public void testToTask() throws Exception {
Network network = PhaseShifterTestCaseFactory.create();
PhaseTapChanger tapChanger = network.getTwoWindingsTransformer("PS1").getPhaseTapChanger();
assertEquals(1, tapChanger.getTapPosition());
TapChangeAction action = new TapChangeAction("PS1", 2);
ModificationTask task = action.toTask();
try (FileSystem fileSystem = Jimfs.newFileSystem(Configuration.unix())) {
Path localDir = fileSystem.getPath("/tmp");
ComputationManager computationManager = new LocalComputationManager(localDir);
task.modify(network, computationManager);
assertEquals(2, tapChanger.getTapPosition());
try {
action.toTask(null);
fail();
} catch (UnsupportedOperationException exc) {
}
}
}
}