399259ad8fee6da48bad163570220ee3cbb96ef9
[appc.git] /
1 /*
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2018 Nokia.
6  * =============================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.appc.flow.controller.ResponseHandlerImpl;
21
22 import static org.junit.Assert.assertEquals;
23
24 import java.util.Collections;
25 import org.junit.Test;
26 import org.onap.appc.flow.controller.data.ResponseAction;
27 import org.onap.appc.flow.controller.data.Transaction;
28
29 public class DefaultResponseHandlerTest {
30
31     @Test
32     public void handlerResponse_shouldReturnEmptyResponseAction_whenTransactionResponsesAreNull() {
33         Transaction transaction = new Transaction();
34         assertDefaultResponseAction(transaction);
35     }
36
37     @Test
38     public void handlerResponse_shouldReturnEmptyResponseAction_whenTransactionResponsesAreEmpty() {
39         Transaction transaction = new Transaction();
40         transaction.setResponses(Collections.emptyList());
41         assertDefaultResponseAction(transaction);
42     }
43
44     private void assertDefaultResponseAction(Transaction transaction) {
45         // GIVEN
46         ResponseAction expectedResponseAction = new ResponseAction();
47
48         // WHEN
49         ResponseAction responseAction = new DefaultResponseHandler().handlerResponse(transaction);
50
51         // THEN
52         assertEquals(expectedResponseAction.isIntermediateMessage(), responseAction.isIntermediateMessage());
53         assertEquals(expectedResponseAction.getJump(), responseAction.getJump());
54         assertEquals(expectedResponseAction.getRetry(), responseAction.getRetry());
55         assertEquals(expectedResponseAction.getWait(), responseAction.getWait());
56         assertEquals(expectedResponseAction.isIgnore(), responseAction.isIgnore());
57         assertEquals(expectedResponseAction.isStop(), responseAction.isStop());
58         assertEquals(expectedResponseAction.toString(), responseAction.toString());
59     }
60 }