/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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 org.apache.flink.runtime.scheduler;

import org.apache.flink.runtime.JobException;
import org.apache.flink.runtime.concurrent.FutureUtils;
import org.apache.flink.runtime.executiongraph.ExecutionVertex;

import java.util.concurrent.CompletableFuture;

import static org.apache.flink.util.Preconditions.checkNotNull;

/**
 * Allows to fail ExecutionVertex operations for testing.
 */
public class FailingExecutionVertexOperationsDecorator implements ExecutionVertexOperations {

	private final ExecutionVertexOperations delegate;

	private boolean failDeploy;

	private boolean failCancel;

	public FailingExecutionVertexOperationsDecorator(final ExecutionVertexOperations delegate) {
		this.delegate = checkNotNull(delegate);
	}

	@Override
	public void deploy(final ExecutionVertex executionVertex) throws JobException {
		if (failDeploy) {
			throw new RuntimeException("Expected");
		} else {
			delegate.deploy(executionVertex);
		}
	}

	@Override
	public CompletableFuture<?> cancel(final ExecutionVertex executionVertex) {
		if (failCancel) {
			return FutureUtils.completedExceptionally(new RuntimeException("Expected"));
		} else {
			return delegate.cancel(executionVertex);
		}
	}

	public void enableFailDeploy() {
		failDeploy = true;
	}

	public void disableFailDeploy() {
		failDeploy = false;
	}

	public void enableFailCancel() {
		failCancel = true;
	}

	public void disableFailCancel() {
		failCancel = false;
	}
}

@@ -897,64 +897,8 @@
 on;%0A
-import org.apache.flink.runtime.concurrent.FutureUtils;%0A
 impo
@@ -957,16 +957,16 @@
 Vertex;%0A
+
 %0Aimport 
@@ -1318,38 +1318,8 @@
 y;%0A%0A
-%09private boolean failCancel;%0A%0A
 %09pub
@@ -1757,119 +1757,8 @@
 ) %7B%0A
-%09%09if (failCancel) %7B%0A%09%09%09return FutureUtils.completedExceptionally(new RuntimeException(%22Expected%22));%0A%09%09%7D else %7B%0A
 %09%09%09r
@@ -1793,28 +1793,24 @@
 ionVertex);%0A
-%09%09%7D%0A
 %09%7D%0A%0A%09public 
@@ -1925,125 +1925,6 @@
 %09%7D%0A%0A
-%09public void enableFailCancel() %7B%0A%09%09failCancel = true;%0A%09%7D%0A%0A%09public void disableFailCancel() %7B%0A%09%09failCancel = false;%0A%09%7D%0A
 %7D%0A

Remove unused methods from FailingExecutionVertexOperationsDecorator