2 * Copyright (c) 2016 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package io.fd.honeycomb.translate.v3po;
19 import static org.hamcrest.CoreMatchers.is;
20 import static org.hamcrest.CoreMatchers.not;
21 import static org.hamcrest.Matchers.empty;
22 import static org.junit.Assert.assertNotNull;
23 import static org.junit.Assert.assertThat;
24 import static org.mockito.MockitoAnnotations.initMocks;
26 import com.google.inject.Guice;
27 import com.google.inject.Inject;
28 import com.google.inject.name.Named;
29 import com.google.inject.testing.fieldbinder.Bind;
30 import com.google.inject.testing.fieldbinder.BoundFieldModule;
31 import io.fd.honeycomb.translate.MappingContext;
32 import io.fd.honeycomb.translate.read.ReaderFactory;
33 import io.fd.honeycomb.translate.impl.read.registry.CompositeReaderRegistryBuilder;
34 import io.fd.honeycomb.translate.impl.write.registry.FlatWriterRegistryBuilder;
35 import io.fd.honeycomb.translate.write.WriterFactory;
36 import java.util.HashSet;
38 import org.junit.Before;
39 import org.junit.Test;
40 import org.mockito.Mock;
41 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
42 import io.fd.vpp.jvpp.core.future.FutureJVppCore;
44 public class V3poModuleTest {
46 @Named("honeycomb-context")
49 private MappingContext mappingContext;
51 @Named("honeycomb-initializer")
54 private DataBroker honeycombInitializer;
56 @Named("honeycomb-context")
59 private DataBroker honeycombContext;
63 private FutureJVppCore futureJVppCore;
66 private Set<ReaderFactory> readerFactories = new HashSet<>();
69 private Set<WriterFactory> writerFactories = new HashSet<>();
74 Guice.createInjector(new V3poModule(), BoundFieldModule.of(this)).injectMembers(this);
78 public void testReaderFactories() throws Exception {
79 assertThat(readerFactories, is(not(empty())));
81 // Test registration process (all dependencies present, topological order of readers does exist, etc.)
82 final CompositeReaderRegistryBuilder registryBuilder = new CompositeReaderRegistryBuilder();
83 readerFactories.stream().forEach(factory -> factory.init(registryBuilder));
84 assertNotNull(registryBuilder.build());
88 public void testWriterFactories() throws Exception {
89 assertThat(writerFactories, is(not(empty())));
91 // Test registration process (all dependencies present, topological order of writers does exist, etc.)
92 final FlatWriterRegistryBuilder registryBuilder = new FlatWriterRegistryBuilder();
93 writerFactories.stream().forEach(factory -> factory.init(registryBuilder));
94 assertNotNull(registryBuilder.build());