1 /** 2 * Copyright (C) 2014 Google Inc. 3 * 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 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 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. 15 */ 16 17 package com.google.inject.multibindings; 18 19 import com.google.inject.multibindings.Element.Type; 20 21 import junit.framework.TestCase; 22 23 /** 24 * Tests for {@link RealElement}. 25 */ 26 public class RealElementTest extends TestCase { 27 28 private Element systemElement; 29 private RealElement realElement; 30 setUp()31 @Override protected void setUp() throws Exception { 32 this.systemElement = Holder.class.getAnnotation(Element.class); 33 this.realElement = new RealElement("b", Type.MULTIBINDER, "a", 1); 34 } 35 testEquals()36 public void testEquals() { 37 assertEquals(systemElement, realElement); 38 assertEquals(realElement, systemElement); 39 } 40 testHashCode()41 public void testHashCode() { 42 assertEquals(systemElement.hashCode(), realElement.hashCode()); 43 } 44 testProperties()45 public void testProperties() { 46 assertEquals("a", realElement.keyType()); 47 assertEquals("b", realElement.setName()); 48 assertEquals(Type.MULTIBINDER, realElement.type()); 49 assertEquals(1, realElement.uniqueId()); 50 } 51 52 53 @Element(keyType = "a", setName = "b", type = Type.MULTIBINDER, uniqueId = 1) 54 static class Holder {} 55 56 } 57