Skip to main content
summaryrefslogtreecommitdiffstats
blob: 0fd641fc76eecd44050e570f62ec0fdfc8ad8815 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*******************************************************************************
 * Copyright (c) 2009 Tasktop Technologies and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     Tasktop Technologies - initial API and implementation
 *******************************************************************************/
package org.eclipse.equinox.p2.discovery.tests.core.mock;

import org.eclipse.equinox.internal.p2.discovery.model.CatalogItem;
import org.eclipse.equinox.internal.p2.discovery.model.FeatureFilter;
import org.eclipse.equinox.internal.p2.discovery.model.Icon;
import org.eclipse.equinox.internal.p2.discovery.model.Overview;
import org.eclipse.equinox.internal.p2.discovery.model.Tag;

/**
 * @author David Green
 */
public class CatalogItemMockFactory extends AbstractMockFactory<CatalogItem> {

	public CatalogItemMockFactory() {
	}

	@Override
	protected void populateMockData() {

		// mock up some data

		getMockObject().setSource(source);

		name("Connector " + seed).id(CatalogItemMockFactory.class.getPackage().getName() + ".connector" + seed)
				.siteUrl("http://example.nodomain/some/path/updateSite3.x/")
				.tag(new Tag("", ""))
				.license(seed % 2 == 0 ? "EPL 1.0" : "APL 2.0")
				.description("a connector for the Example Task System versions 1.0 - 5.3")
				.categoryId("example")
				.provider("Testing 123 Inc.");

		Icon icon = new Icon();
		icon.setImage128("images/ico128.png");
		icon.setImage16("images/ico16.png");
		icon.setImage32("images/ico32.png");
		icon.setImage64("images/ico64.png");

		Overview overview = new Overview();
		overview.setScreenshot("images/screenshot-main.png");
		overview.setSummary("some long text that summarizes the connector");
		overview.setUrl("http://example.nodomain/some/path/updateSite3.x/overview.html");

		icon(icon).overview(overview);
		overview.setItem(getMockObject());
	}

	@Override
	protected CatalogItem createMockObject() {
		return new CatalogItem();
	}

	public CatalogItemMockFactory categoryId(String categoryId) {
		getMockObject().setCategoryId(categoryId);
		return this;
	}

	public CatalogItemMockFactory description(String description) {
		getMockObject().setDescription(description);
		return this;
	}

	public CatalogItemMockFactory icon(Icon icon) {
		getMockObject().setIcon(icon);
		return this;
	}

	public CatalogItemMockFactory id(String id) {
		getMockObject().setId(id);
		return this;
	}

	public CatalogItemMockFactory tag(Tag tag) {
		getMockObject().addTag(tag);
		return this;
	}

	public CatalogItemMockFactory license(String license) {
		getMockObject().setLicense(license);
		return this;
	}

	public CatalogItemMockFactory name(String name) {
		getMockObject().setName(name);
		return this;
	}

	public CatalogItemMockFactory overview(Overview overview) {
		getMockObject().setOverview(overview);
		return this;
	}

	public CatalogItemMockFactory platformFilter(String platformFilter) {
		getMockObject().setPlatformFilter(platformFilter);
		return this;
	}

	public CatalogItemMockFactory provider(String provider) {
		getMockObject().setProvider(provider);
		return this;
	}

	public CatalogItemMockFactory siteUrl(String siteUrl) {
		getMockObject().setSiteUrl(siteUrl);
		return this;
	}

	public CatalogItemMockFactory featureFilter(String featureId, String versionRange) {
		FeatureFilter featureFilter = new FeatureFilter();
		featureFilter.setItem(getMockObject());
		featureFilter.setFeatureId(featureId);
		featureFilter.setVersion(versionRange);
		getMockObject().getFeatureFilter().add(featureFilter);
		return this;
	}
}

Back to the top