Skip to content

Test item leaf

Ivan edited this page Dec 1, 2019 · 2 revisions

Test item leaf

TestItemLeaf represents TestItem reported to the Report Portal instance. It contains itemId field to provide reference to the TestItem:

    private final Maybe<String> itemId;    
  
    public Maybe<String> getItemId() {
			return itemId;
		}

childItems field is required for retrieving descendants of current TestItemLeaf:

    private final Map<ItemTreeKey, TestItemLeaf> childItems;    
  
    public Map<ItemTreeKey, TestItemLeaf> getChildItems() {
			return childItems;
		}

These fields are mandatory. Field parentId is required for accessing ancestor id of current TestItem and may be NULL if current TestItemLeaf represents root TestItem:

    @Nullable
    private Maybe<String> parentId;    

    @Nullable
    public Maybe<String> getParentId() {
			return parentId;
		}

Field finishResponse contains Maybe<OperationCompletionRS> with response message of successfully finished TestItem that should be initialized after calling finish test item method by agent and required to provide correct finish TestItem requests order (using ItemTreeReporter(wiki)):

    @Nullable
    private Maybe<OperationCompletionRS> finishResponse;    

    @Nullable
    public Maybe<OperationCompletionRS> getFinishResponse() {
			return finishResponse;
		}

Mandatory and optional fields may be initialized using one of the following constructors:

    private TestItemLeaf(Maybe<String> itemId, int expectedChildrenCount) {
			this.itemId = itemId;
			this.childItems = new ConcurrentHashMap<ItemTreeKey, TestItemLeaf>(expectedChildrenCount);
		}

    private TestItemLeaf(Maybe<String> itemId, ConcurrentHashMap<ItemTreeKey, TestItemLeaf> childItems) {
			this.itemId = itemId;
			this.childItems = childItems;
		}

    private TestItemLeaf(@Nullable Maybe<String> parentId, Maybe<String> itemId, int expectedChildrenCount) {
			this(itemId, expectedChildrenCount);
			this.parentId = parentId;
		}

    private TestItemLeaf(@Nullable Maybe<String> parentId, Maybe<String> itemId,
				ConcurrentHashMap<ItemTreeKey, TestItemLeaf> childItems) {
			this(itemId, childItems);
			this.parentId = parentId;
		}

All constructors have private access and can be called only from TestItemTree(wiki) static methods:

    public static TestItemTree.TestItemLeaf createTestItemLeaf(Maybe<String> itemId, int expectedChildrenCount) {
		return new TestItemTree.TestItemLeaf(itemId, expectedChildrenCount);
	}

    public static TestItemTree.TestItemLeaf createTestItemLeaf(Maybe<String> parentId, Maybe<String> itemId, int expectedChildrenCount) {
		return new TestItemTree.TestItemLeaf(parentId, itemId, expectedChildrenCount);
	}

    public static TestItemTree.TestItemLeaf createTestItemLeaf(Maybe<String> itemId,
			ConcurrentHashMap<ItemTreeKey, TestItemLeaf> childItems) {
		return new TestItemTree.TestItemLeaf(itemId, childItems);
	}

    public static TestItemTree.TestItemLeaf createTestItemLeaf(Maybe<String> parentId, Maybe<String> itemId,
			ConcurrentHashMap<ItemTreeKey, TestItemLeaf> childItems) {
		return new TestItemTree.TestItemLeaf(parentId, itemId, childItems);
	}