Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tests/org.eclipse.platform.discovery.test.testutils/src/org/eclipse/platform/discovery/testutils/utils/model/SubdestinationBuilder.java')
-rw-r--r--tests/org.eclipse.platform.discovery.test.testutils/src/org/eclipse/platform/discovery/testutils/utils/model/SubdestinationBuilder.java54
1 files changed, 31 insertions, 23 deletions
diff --git a/tests/org.eclipse.platform.discovery.test.testutils/src/org/eclipse/platform/discovery/testutils/utils/model/SubdestinationBuilder.java b/tests/org.eclipse.platform.discovery.test.testutils/src/org/eclipse/platform/discovery/testutils/utils/model/SubdestinationBuilder.java
index 5a2d3d7..8a79065 100644
--- a/tests/org.eclipse.platform.discovery.test.testutils/src/org/eclipse/platform/discovery/testutils/utils/model/SubdestinationBuilder.java
+++ b/tests/org.eclipse.platform.discovery.test.testutils/src/org/eclipse/platform/discovery/testutils/utils/model/SubdestinationBuilder.java
@@ -1,42 +1,50 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG, Walldorf
+ * Copyright (c) 2011 SAP AG, Walldorf.
* 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:
- * SAP AG - initial API and implementation
+ * SAP AG - initial API and implementation
*******************************************************************************/
package org.eclipse.platform.discovery.testutils.utils.model;
+import java.util.Arrays;
import java.util.HashSet;
-import java.util.Set;
import org.eclipse.platform.discovery.runtime.api.IConflict;
import org.eclipse.platform.discovery.runtime.api.ISearchSubdestination;
-import static org.mockito.Mockito.*;
+import org.mockito.Mockito;
-public class SubdestinationBuilder {
-
- public ISearchSubdestination buildSubdestination(String id, String categoryId, String objectTypeId, String... conflicts) {
- ISearchSubdestination result = mock(ISearchSubdestination.class);
- when(result.getId()).thenReturn(id);
- when(result.getDestinationCategoryId()).thenReturn(categoryId);
- when(result.getObjectTypeId()).thenReturn(objectTypeId);
- Set<IConflict> conflictsSet = buildConflicts(conflicts);
- when(result.getConflictingSubd()).thenReturn(conflictsSet);
- return result;
+public class SubdestinationBuilder extends DescriptiveObjectBuilder<ISearchSubdestination>
+{
+ public SubdestinationBuilder()
+ {
+ super(Mockito.mock(ISearchSubdestination.class));
}
-
- private Set<IConflict> buildConflicts(String[] conflictIds) {
- Set<IConflict> result = new HashSet<IConflict>();
- for(String conflictId:conflictIds) {
- IConflict conflict = mock(IConflict.class);
- when(conflict.getconflictingSubdID()).thenReturn(conflictId);
- result.add(conflict);
- }
- return result;
+
+ public SubdestinationBuilder withDestCategoryId(final String destCategoryId)
+ {
+ Mockito.stub(object().getDestinationCategoryId()).toReturn(destCategoryId);
+ return this;
+ }
+
+ public SubdestinationBuilder forObjectType(final String objectTypeId)
+ {
+ Mockito.stub(object().getObjectTypeId()).toReturn(objectTypeId);
+ return this;
}
+ public SubdestinationBuilder defaultSelected(final boolean defaultSelected)
+ {
+ Mockito.stub(object().isDefaultSelected()).toReturn(defaultSelected);
+ return this;
+ }
+
+ public SubdestinationBuilder conflictsTo(IConflict... conflicts)
+ {
+ Mockito.stub(object().getConflictingSubd()).toReturn(new HashSet<IConflict>(Arrays.asList(conflicts)));
+ return this;
+ }
}

Back to the top