Binding2-dom-adapter JUnit code coverage increase
[mdsal.git] / binding2 / mdsal-binding2-dom-adapter / src / test / java / org / opendaylight / mdsal / binding / javav2 / dom / adapter / spi / builder / AdapterBuilderTest.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.mdsal.binding.javav2.dom.adapter.spi.builder;
10
11 import static org.junit.Assert.assertTrue;
12
13 import com.google.common.collect.ClassToInstanceMap;
14 import com.google.common.collect.MutableClassToInstanceMap;
15 import java.util.Map;
16 import java.util.Set;
17 import org.junit.Test;
18
19 public class AdapterBuilderTest extends AdapterBuilder {
20
21     private static final ClassToInstanceMap<Object> DELEGATES = MutableClassToInstanceMap.create();
22
23     @Test
24     public void buildTest() throws Exception {
25         this.addDelegate(String.class, "test");
26         DELEGATES.putAll((Map) this.build());
27         assertTrue(DELEGATES.containsValue("test"));
28         this.addDelegate(Object.class, "test2");
29         DELEGATES.putAll((Map) this.build());
30         assertTrue(DELEGATES.containsValue("test"));
31         assertTrue(DELEGATES.get(Object.class).equals("test2"));
32     }
33
34     @Override
35     public Set<? extends Class> getRequiredDelegates() {
36         return DELEGATES.keySet();
37     }
38
39     @Override
40     protected Object createInstance(ClassToInstanceMap delegates) {
41         return delegates;
42     }
43 }