/*
 * Copyright 2016-present Open Networking Laboratory
 *
 * 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 org.onosproject.store.service;

import com.google.common.collect.Sets;

import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;

/**
 * Test implementation of topic.
 */
public class TestTopic<T> implements Topic<T> {
    private final String name;
    private final Set<Consumer<T>> callbacks = Sets.newConcurrentHashSet();

    public TestTopic(String name) {
        this.name = name;
    }

    @Override
    public CompletableFuture<Void> publish(T message) {
        callbacks.forEach(c -> c.accept(message));
        return CompletableFuture.completedFuture(null);
    }

    @Override
    public CompletableFuture<Void> subscribe(Consumer<T> callback) {
        callbacks.add(callback);
        return CompletableFuture.completedFuture(null);
    }

    @Override
    public CompletableFuture<Void> unsubscribe(Consumer<T> callback) {
        callbacks.remove(callback);
        return CompletableFuture.completedFuture(null);
    }

    @Override
    public String name() {
        return name;
    }

    @Override
    public Type primitiveType() {
        return Type.TOPIC;
    }
}

@@ -685,19 +685,19 @@
 collect.
-Set
+Map
 s;%0A%0Aimpo
@@ -709,19 +709,19 @@
 va.util.
-Set
+Map
 ;%0Aimport
@@ -761,16 +761,54 @@
 Future;%0A
+import java.util.concurrent.Executor;%0A
 import j
@@ -974,19 +974,19 @@
 e final 
-Set
+Map
 %3CConsume
@@ -989,16 +989,26 @@
 sumer%3CT%3E
+, Executor
 %3E callba
@@ -1017,33 +1017,31 @@
 s = 
-Set
+Map
 s.new
-Concurrent
+Identity
 Hash
-Set
+Map
 ();%0A
@@ -1210,30 +1210,110 @@
 ach(
-c -%3E c.accept(message)
+(k, v) -%3E %7B%0A            v.execute(() -%3E %7B%0A                k.accept(message);%0A            %7D);%0A        %7D
 );%0A 
@@ -1445,32 +1445,51 @@
 umer%3CT%3E callback
+, Executor executor
 ) %7B%0A        call
@@ -1498,11 +1498,11 @@
 cks.
-add
+put
 (cal
@@ -1498,32 +1498,42 @@
 cks.put(callback
+, executor
 );%0A        retur

Update TestTopic to confirm to the new Topic API