OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2014, the Dart project authors. |
| 3 * |
| 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except |
| 5 * in compliance with the License. You may obtain a copy of the License at |
| 6 * |
| 7 * http://www.eclipse.org/legal/epl-v10.html |
| 8 * |
| 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
| 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
| 11 * or implied. See the License for the specific language governing permissions a
nd limitations under |
| 12 * the License. |
| 13 */ |
| 14 package com.google.dart.engine.internal.index.file; |
| 15 |
| 16 import com.google.dart.engine.context.AnalysisContext; |
| 17 import com.google.dart.engine.element.Element; |
| 18 import com.google.dart.engine.element.ElementLocation; |
| 19 import com.google.dart.engine.index.Relationship; |
| 20 import com.google.dart.engine.internal.element.ElementLocationImpl; |
| 21 |
| 22 import junit.framework.TestCase; |
| 23 |
| 24 import static org.mockito.Mockito.mock; |
| 25 import static org.mockito.Mockito.when; |
| 26 |
| 27 public class RelationKeyDataTest extends TestCase { |
| 28 private AnalysisContext context = mock(AnalysisContext.class); |
| 29 private StringCodec stringCodec = new StringCodec(); |
| 30 private ElementCodec elementCodec = new ElementCodec(stringCodec); |
| 31 private RelationshipCodec relationshipCodec = new RelationshipCodec(stringCode
c); |
| 32 |
| 33 public void test_newFromData() throws Exception { |
| 34 RelationKeyData keyData = new RelationKeyData(1, 2); |
| 35 // equals |
| 36 assertFalse(keyData.equals(null)); |
| 37 assertTrue(keyData.equals(keyData)); |
| 38 } |
| 39 |
| 40 public void test_newFromObjects() throws Exception { |
| 41 Relationship relationship = Relationship.getRelationship("my-relationship"); |
| 42 // prepare Element |
| 43 Element element; |
| 44 { |
| 45 element = mock(Element.class); |
| 46 ElementLocation location = new ElementLocationImpl(new String[] {"foo", "b
ar"}); |
| 47 when(element.getLocation()).thenReturn(location); |
| 48 when(context.getElement(location)).thenReturn(element); |
| 49 } |
| 50 // create RelationKeyData |
| 51 RelationKeyData keyData = new RelationKeyData( |
| 52 elementCodec, |
| 53 relationshipCodec, |
| 54 element, |
| 55 relationship); |
| 56 // touch |
| 57 keyData.hashCode(); |
| 58 // equals |
| 59 assertFalse(keyData.equals(null)); |
| 60 assertTrue(keyData.equals(keyData)); |
| 61 } |
| 62 } |
OLD | NEW |