@@ -0,0 +1,3550 @@
+package org.museautomation.core.task.plugins.state;%0A%0Aimport org.junit.jupiter.api.*;%0Aimport org.museautomation.core.task.state.*;%0A%0Aimport javax.annotation.*;%0Aimport java.util.*;%0A%0A/**%0A * @author Christopher L Merrill (see LICENSE.txt for license details)%0A */%0Apublic class StateContainerTests%0A    %7B%0A    @Test%0A    public void addState()%0A        %7B%0A        _container.addState(_state1);%0A        Assertions.assertTrue(_states_added.contains(_state1));%0A        Assertions.assertTrue(_states_replaced.isEmpty());%0A        Assertions.assertTrue(_container.contains(_state1));%0A%0A        _container.addState(_state2);%0A        Assertions.assertTrue(_states_added.contains(_state2));%0A        %7D%0A%0A    @Test%0A    public void removeState()%0A        %7B%0A        _container.addState(_state1);%0A%0A        _container.removeState(_state1);%0A        Assertions.assertTrue(_states_removed.contains(_state1));%0A        Assertions.assertTrue(_states_replaced.isEmpty());%0A        Assertions.assertFalse(_container.contains(_state1));%0A%0A        _container.addState(_state1);%0A        _container.addState(_state2);%0A%0A        _states_removed.clear();%0A        _container.removeState(_state1);%0A        Assertions.assertTrue(_states_removed.contains(_state1));%0A        Assertions.assertFalse(_container.contains(_state1));%0A        Assertions.assertTrue(_container.contains(_state2));%0A        %7D%0A%0A    @Test%0A    public void replaceState()%0A        %7B%0A        _container.addState(_state2);%0A%0A        _states_added.clear();%0A        _states_replaced.clear();%0A        _container.replaceState(_state2, _state1);%0A        Assertions.assertTrue(_states_removed.isEmpty());%0A        Assertions.assertTrue(_states_added.isEmpty());%0A        Assertions.assertEquals(_state1, _states_replaced.get(_state2));%0A        Assertions.assertTrue(_container.contains(_state1));%0A        Assertions.assertFalse(_container.contains(_state2));%0A        %7D%0A%0A    @Test%0A    public void listenerRemoved()%0A        %7B%0A        _container.removeStateListener(_listener);%0A        _container.addState(_state1);%0A        _container.replaceState(_state1, _state2);%0A        _container.removeState(_state2);%0A%0A        Assertions.assertTrue(_states_added.isEmpty());%0A        Assertions.assertTrue(_states_removed.isEmpty());%0A        Assertions.assertTrue(_states_replaced.isEmpty());%0A        %7D%0A%0A%0A    @BeforeEach%0A    public void setup()%0A        %7B%0A        _state1.setStateDefinitionId(%22state1%22);%0A        _state2.setStateDefinitionId(%22state2%22);%0A        _container.addStateListener(_listener);%0A        %7D%0A%0A    private InterTaskState _state1 = new InterTaskState();%0A    private InterTaskState _state2 = new InterTaskState();%0A    private StateContainer _container = new BasicStateContainer();%0A    private List%3CInterTaskState%3E _states_added = new ArrayList%3C%3E();%0A    private List%3CInterTaskState%3E _states_removed = new ArrayList%3C%3E();%0A    private Map%3CInterTaskState, InterTaskState%3E _states_replaced = new HashMap%3C%3E();%0A%0A    StateContainer.StateContainerChangeListener _listener = new StateContainer.StateContainerChangeListener()%0A        %7B%0A        @Override%0A        public void stateAdded(@Nonnull InterTaskState state)%0A            %7B%0A            _states_added.add(state);%0A            %7D%0A%0A        @Override%0A        public void stateRemoved(@Nonnull InterTaskState state)%0A            %7B%0A            _states_removed.add(state);%0A            %7D%0A%0A        @Override%0A        public void stateReplaced(@Nonnull InterTaskState old_state, @Nonnull InterTaskState new_state)%0A            %7B%0A            _states_replaced.put(old_state, new_state);%0A            %7D%0A        %7D;%0A    %7D

add unit tests for StateContainer & listeners