/*
 * Copyright 2017 Crown Copyright
 *
 * 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 stroom.node.mock;

import stroom.node.api.NodeService;
import stroom.node.api.FindNodeCriteria;

import javax.inject.Singleton;
import javax.ws.rs.client.Invocation.Builder;
import javax.ws.rs.core.Response;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import java.util.function.Supplier;

/**
 * Mock class that manages one node.
 */
@Singleton
public class MockNodeService implements NodeService {
    private MockNodeInfo nodeInfo = new MockNodeInfo();

    @Override
    public String getBaseEndpointUrl(final String nodeName) {
        return null;
    }

    @Override
    public boolean isEnabled(final String nodeName) {
        return nodeName.equals(nodeInfo.getThisNodeName());
    }

    @Override
    public int getPriority(final String nodeName) {
        if (nodeName.equals(nodeInfo.getThisNodeName())) {
            return 1;
        }
        return 0;
    }

    @Override
    public List<String> findNodeNames(final FindNodeCriteria criteria) {
        return Collections.singletonList(nodeInfo.getThisNodeName());
    }

    @Override
    public <T_RESP> T_RESP remoteRestResult(final String nodeName,
                                            final String fullPath,
                                            final Supplier<T_RESP> localSupplier,
                                            final Function<Builder, Response> responseBuilderFunc,
                                            final Function<Response, T_RESP> responseMapper) {
        return localSupplier.get();
    }
}

@@ -2155,11 +2155,318 @@
 );%0A    %7D
+%0A%0A    @Override%0A    public void remoteRestCall(final String nodeName,%0A                               final String fullPath,%0A                               final Runnable localRunnable,%0A                               final Function%3CBuilder, Response%3E responseBuilderFunc) %7B%0A        localRunnable.run();%0A    %7D
 %0A%7D%0A

Fix compile error