2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
25 package org.openecomp.appc.statemachine;
28 import org.junit.Test;
29 import org.openecomp.appc.statemachine.objects.InvalidInputException;
32 public class TestStateMachine {
35 public void handleEvent() throws InvalidInputException {
37 // MetadataReader metadataReader = new MetadataReader();
38 // StateMachineMetadata metadata = metadataReader.readMetadata(null);
40 // StateMachine machine = StateMachineFactory.getStateMachine(metadata);
43 // Testing Positive Scenario passing the valid events and validating the StateMachineResponse
45 // for(State state:metadata.getStates()){
47 // for(Transition transition:state.getTransitions()){
48 // Event event = transition.getEvent();
49 // State nextState = transition.getNextState();
51 // StateMachineResponse response = machine.handleEvent(state,event);
52 // Assert.assertEquals(response.getNextState(),nextState);
53 // Assert.assertEquals(response.getResponse(),Response.VALID_TRANSITION);
58 // Testing Negative Scenarios, 1. Passing the valid Events for which Transition is not defined in
59 // Metadata and validating the StateMachineResponse 2. Passing the invalid events which are not
60 // registered as events in the StateMachineMetadata and validating StateMachineResponse
62 // for(State state:metadata.getStates()){
64 // for(Transition transition:state.getTransitions()){
65 // List<Event> negativeEvents = getNegativeEvents(state,metadata.getEvents());
67 // for(Event negativeEvent:negativeEvents){
68 // StateMachineResponse response = machine.handleEvent(state,negativeEvent);
69 // Assert.assertEquals(response.getNextState(),null);
70 // Assert.assertEquals(response.getResponse(),Response.NO_TRANSITION_DEFINED);
72 // boolean flag =false;
74 // response = machine.handleEvent(state,new Event("PUT"));
76 // catch(InvalidInputException e){
79 // Assert.assertTrue(flag);
86 // private List<Event> getNegativeEvents(State state,Set<Event> events) {
87 // List<Event> negativeEventList = new ArrayList<>();
88 // negativeEventList.addAll(events);
90 // for(Transition transition: state.getTransitions()){
91 // negativeEventList.remove(transition.getEvent());
93 // return negativeEventList;