+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
package org.opendaylight.groupbasedpolicy.neutron.mapper.test;
import static com.google.common.base.Preconditions.checkState;
+import javax.annotation.Nonnull;
import java.io.IOException;
+import java.util.Collection;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSet.Builder;
import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.Tenant;
import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.ImmutableSet.Builder;
-
/**
* Loads only modules of GBP and it's dependencies for data broker.
- * <br>Therefore this implementation is faster than {@link AbstractDataBrokerTest}
+ * <br>
+ * Therefore this implementation is faster than {@link AbstractDataBrokerTest}
*/
-public class GbpDataBrokerTest extends AbstractDataBrokerTest {
+public abstract class CustomDataBrokerTest extends AbstractDataBrokerTest {
@Override
protected Iterable<YangModuleInfo> getModuleInfos() throws Exception {
Builder<YangModuleInfo> moduleInfoSet = ImmutableSet.<YangModuleInfo>builder();
- loadModuleInfos(Tenant.class, moduleInfoSet);
+ for (Class<?> clazz : getClassesFromModules()) {
+ loadModuleInfos(clazz, moduleInfoSet);
+ }
return moduleInfoSet.build();
}
- public static void loadModuleInfos(Class<?> clazzFromModule, Builder<YangModuleInfo> moduleInfoSet) throws Exception {
+ /**
+ * @return a class from every yang module which needs to be loaded. Cannot return {@code null}
+ * or empty collection.
+ */
+ public abstract @Nonnull Collection<Class<?>> getClassesFromModules();
+
+ public static void loadModuleInfos(Class<?> clazzFromModule, Builder<YangModuleInfo> moduleInfoSet)
+ throws Exception {
YangModuleInfo moduleInfo = BindingReflections.getModuleInfo(clazzFromModule);
checkState(moduleInfo != null, "Module Info for %s is not available.", clazzFromModule);
collectYangModuleInfo(moduleInfo, moduleInfoSet);