update copyright
[fedora-idea.git] / plugins / junit / src / com / intellij / execution / junit2 / TestRootImpl.java
blob0cd9326035f1a6f44075f2e2b714f6d377152947
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
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 com.intellij.execution.junit2;
19 import com.intellij.execution.junit2.info.ClassBasedInfo;
20 import com.intellij.execution.junit2.info.DisplayTestInfoExtractor;
21 import com.intellij.execution.junit2.segments.ObjectReader;
22 import com.intellij.util.containers.HashMap;
24 import java.util.List;
26 public class TestRootImpl implements TestRoot {
27 private final TestProxy myRootTest;
28 private final HashMap<String,TestProxy> myKnownDynamicParents = new HashMap<String, TestProxy>();
30 public TestRootImpl(final TestProxy rootTest) {
31 myRootTest = rootTest;
34 public void addChild(final TestProxy child) {
35 if (child == myRootTest)
36 return;
37 getDynamicParentFor(child).addChild(child);
40 private TestProxy getDynamicParentFor(final TestProxy child) {
41 final String parentClass = child.getInfo().getComment();
42 TestProxy dynamicParent = myKnownDynamicParents.get(parentClass);
43 if (dynamicParent == null) {
44 dynamicParent = new TestProxy(new DynamicParentInfo(parentClass));
45 myKnownDynamicParents.put(parentClass, dynamicParent);
46 myRootTest.addChild(dynamicParent);
48 return dynamicParent;
51 public TestProxy getRootTest() {
52 return myRootTest;
55 public List<TestProxy> getAllTests() {
56 return getRootTest().getAllTests();
59 private static class DynamicParentInfo extends ClassBasedInfo {
60 public DynamicParentInfo(final String className) {
61 super(DisplayTestInfoExtractor.FOR_CLASS);
62 setClassName(className);
65 public void readPacketFrom(final ObjectReader reader) {