/*
 * Copyright 2019 Wultra s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.getlime.security.powerauth.lib.webflow.authentication.model.converter;

import io.getlime.security.powerauth.lib.dataadapter.model.enumeration.OperationTerminationReason;
import io.getlime.security.powerauth.lib.nextstep.model.enumeration.OperationCancelReason;

/**
 * Converter between operation cancellation reason for Next Step and operation termination reason for AFS.
 */
public class OperationCancellationConverter {

    /**
     * Convert cancellation reason to AFS termination reason.
     * @param cancelReason Reason why operation is being canceled.
     * @return Operation termination reason for AFS.
     */
    public OperationTerminationReason convertCancelReason(OperationCancelReason cancelReason) {
        OperationTerminationReason terminationReason;
        if (cancelReason == null) {
            return OperationTerminationReason.FAILED;
        }
        switch (cancelReason) {
            case INTERRUPTED_OPERATION:
                terminationReason = OperationTerminationReason.INTERRUPTED;
                break;
            case TIMED_OUT_OPERATION:
                terminationReason = OperationTerminationReason.TIMED_OUT;
                break;
            default:
                terminationReason = OperationTerminationReason.FAILED;
        }
        return terminationReason;
    }

}

@@ -1320,62 +1320,8 @@
 ) %7B%0A
-        OperationTerminationReason terminationReason;%0A
     
@@ -1504,35 +1504,22 @@
         
-terminationReason =
+return
  Operati
@@ -1551,39 +1551,16 @@
 RUPTED;%0A
-                break;%0A
         
@@ -1605,35 +1605,22 @@
         
-terminationReason =
+return
  Operati
@@ -1654,31 +1654,8 @@
 UT;%0A
-                break;%0A
     
@@ -1691,27 +1691,14 @@
     
-terminationReason =
+return
  Ope
@@ -1743,42 +1743,8 @@
   %7D%0A
-        return terminationReason;%0A
     

Simplify converter logic