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.internal; 18 19 import com.google.inject.internal.Element.Type; 20 import junit.framework.TestCase; 21 22 /** Tests for {@link com.google.inject.internal.RealElement}. */ 23 public class RealElementTest extends TestCase { 24 25 private Element systemElement; 26 private RealElement realElement; 27 28 @Override setUp()29 protected void setUp() throws Exception { 30 this.systemElement = Holder.class.getAnnotation(Element.class); 31 this.realElement = new RealElement("b", Type.MULTIBINDER, "a", 1); 32 } 33 testEquals()34 public void testEquals() { 35 assertEquals(systemElement, realElement); 36 assertEquals(realElement, systemElement); 37 } 38 testHashCode()39 public void testHashCode() { 40 assertEquals(systemElement.hashCode(), realElement.hashCode()); 41 } 42 testProperties()43 public void testProperties() { 44 assertEquals("a", realElement.keyType()); 45 assertEquals("b", realElement.setName()); 46 assertEquals(Type.MULTIBINDER, realElement.type()); 47 assertEquals(1, realElement.uniqueId()); 48 } 49 50 @Element(keyType = "a", setName = "b", type = Type.MULTIBINDER, uniqueId = 1) 51 static class Holder {} 52 } 53