Skip to main content
summaryrefslogtreecommitdiffstats
blob: 7d9e6b4801bf614d6e54f8a3fa2e3866a5f12061 (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
/*******************************************************************************
 * 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.*;

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

	@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."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$

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

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

		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