Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2013-07-09 00:37:49 +0000
committerRoberto E. Escobar2013-07-29 18:14:28 +0000
commit294b3ef4d8dbf5c76ebaf1709d6d8aafc61ca9f7 (patch)
treeaad48cc2c32f5fe8d1470f57c93c0e7228989b3a
parent7945b8b3e7e554a38bf157b95e7c1d8a97d43757 (diff)
downloadorg.eclipse.osee-294b3ef4d8dbf5c76ebaf1709d6d8aafc61ca9f7.tar.gz
org.eclipse.osee-294b3ef4d8dbf5c76ebaf1709d6d8aafc61ca9f7.tar.xz
org.eclipse.osee-294b3ef4d8dbf5c76ebaf1709d6d8aafc61ca9f7.zip
refactor: Remove use of csv data as input to ORCS tests
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactBuilderImplTest.java64
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactLoaderFactoryImplTest.java22
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/CsvReader.java43
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/CsvRowHandler.java20
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/data.csv24
5 files changed, 49 insertions, 124 deletions
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactBuilderImplTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactBuilderImplTest.java
index d0a7337e468..ef57303021d 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactBuilderImplTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactBuilderImplTest.java
@@ -16,8 +16,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import java.io.IOException;
-import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -105,10 +103,10 @@ public class ArtifactBuilderImplTest {
}
@Test
- public void testRelationCountMatches() throws OseeCoreException, IOException {
+ public void testRelationCountMatches() throws OseeCoreException {
RelationTypes cache = createAndPopulate();
Map<Integer, RelationContainer> containers = getRelationProviderList(cache, 22);
- List<RelationData> datas = getTestData("data.csv");
+ List<RelationData> datas = getTestData();
doSetup(datas, containers);
for (RelationData data : datas) {
@@ -125,10 +123,10 @@ public class ArtifactBuilderImplTest {
@Ignore
@Test
- public void testRelatedArtifactsMatch() throws OseeCoreException, IOException {
+ public void testRelatedArtifactsMatch() throws OseeCoreException {
RelationTypes cache = createAndPopulate();
Map<Integer, RelationContainer> containers = getRelationProviderList(cache, 22);
- List<RelationData> datas = getTestData("data.csv");
+ List<RelationData> datas = getTestData();
doSetup(datas, containers);
checkRelatedArtifacts(containers.get(1), RelationSide.SIDE_B, 2, 3, 4, 5, 6, 7, 8, 9, 10);
@@ -201,18 +199,37 @@ public class ArtifactBuilderImplTest {
String.format("We did not get the expected number of relations back [%d != %d]", size, count), size, count);
}
- private List<RelationData> getTestData(String csvFile) throws IOException {
- URL url = getClass().getResource(csvFile);
- Assert.assertNotNull(url);
-
+ private List<RelationData> getTestData() {
List<RelationData> datas = new ArrayList<RelationData>();
RelationCsvReader csvReader = new RelationCsvReader(datas);
- CsvReader reader = new CsvReader(url.openStream(), csvReader);
- reader.readFile();
+ // #ArtIdA ArtIdB BranchId GammaId ModType Rationale RelationId RelationTypeId
+ csvReader.onRow(1, 1, 2, 1, 1L, ModificationType.NEW, "yay", 1, 1L);
+ csvReader.onRow(1, 1, 3, 1, 1L, ModificationType.NEW, "yay", 2, 1L);
+ csvReader.onRow(1, 1, 4, 1, 1L, ModificationType.NEW, "yay", 3, 1L);
+ csvReader.onRow(1, 1, 5, 1, 1L, ModificationType.NEW, "yay", 4, 1L);
+ csvReader.onRow(1, 1, 6, 1, 1L, ModificationType.NEW, "yay", 5, 1L);
+ csvReader.onRow(1, 1, 7, 1, 1L, ModificationType.NEW, "yay", 6, 1L);
+ csvReader.onRow(1, 1, 8, 1, 1L, ModificationType.NEW, "yay", 7, 1L);
+ csvReader.onRow(1, 1, 9, 1, 1L, ModificationType.NEW, "yay", 8, 1L);
+ csvReader.onRow(1, 1, 10, 1, 1L, ModificationType.NEW, "yay", 9, 1L);
+ csvReader.onRow(3, 3, 11, 1, 1L, ModificationType.NEW, "yay", 10, 1L);
+ csvReader.onRow(3, 1, 3, 1, 1L, ModificationType.NEW, "yay", 10, 1L);
+ csvReader.onRow(3, 3, 12, 1, 1L, ModificationType.NEW, "yay", 11, 1L);
+ csvReader.onRow(3, 3, 13, 1, 1L, ModificationType.NEW, "yay", 12, 1L);
+ csvReader.onRow(3, 3, 14, 1, 1L, ModificationType.NEW, "yay", 13, 1L);
+ csvReader.onRow(3, 3, 15, 1, 1L, ModificationType.NEW, "yay", 14, 1L);
+ csvReader.onRow(3, 3, 16, 1, 1L, ModificationType.NEW, "yay", 15, 1L);
+ csvReader.onRow(4, 4, 17, 1, 1L, ModificationType.NEW, "yay", 16, 1L);
+ csvReader.onRow(4, 4, 18, 1, 1L, ModificationType.NEW, "yay", 17, 1L);
+ csvReader.onRow(4, 4, 19, 1, 1L, ModificationType.NEW, "yay", 18, 1L);
+ csvReader.onRow(4, 4, 20, 1, 1L, ModificationType.NEW, "yay", 19, 1L);
+ csvReader.onRow(4, 4, 21, 1, 1L, ModificationType.NEW, "yay", 20, 1L);
+ csvReader.onRow(4, 4, 22, 1, 1L, ModificationType.NEW, "yay", 21, 1L);
+ csvReader.onRow(4, 4, 2, 1, 1L, ModificationType.NEW, "yay", 21, 1L);
return datas;
}
- public static class RelationCsvReader implements CsvRowHandler {
+ public static class RelationCsvReader {
private final List<RelationData> data;
@@ -220,8 +237,7 @@ public class ArtifactBuilderImplTest {
this.data = data;
}
- @Override
- public void onRow(String... row) {
+ public void onRow(Object... row) {
//ArtIdA,ArtIdB,BranchId,GammaId,ModType,Rationale,RelationId,RelationTypeId
if (row.length != 9) {
Assert.assertTrue("Data file is not formatted correctly", false);
@@ -230,16 +246,16 @@ public class ArtifactBuilderImplTest {
VersionData version = mock(VersionData.class);
RelationData relationRow = Mockito.mock(RelationData.class);
- when(version.getBranchId()).thenReturn(Integer.parseInt(row[3]));
- when(version.getGammaId()).thenReturn(Long.parseLong(row[4]));
+ when(version.getBranchId()).thenReturn((Integer) row[3]);
+ when(version.getGammaId()).thenReturn((Long) row[4]);
- when(relationRow.getParentId()).thenReturn(Integer.parseInt(row[0]));
- when(relationRow.getArtIdA()).thenReturn(Integer.parseInt(row[1]));
- when(relationRow.getArtIdB()).thenReturn(Integer.parseInt(row[2]));
- when(relationRow.getModType()).thenReturn(ModificationType.valueOf(row[5]));
- when(relationRow.getRationale()).thenReturn(row[6]);
- when(relationRow.getLocalId()).thenReturn(Integer.parseInt(row[7]));
- when(relationRow.getTypeUuid()).thenReturn(Long.parseLong(row[8]));
+ when(relationRow.getParentId()).thenReturn((Integer) row[0]);
+ when(relationRow.getArtIdA()).thenReturn((Integer) row[1]);
+ when(relationRow.getArtIdB()).thenReturn((Integer) row[2]);
+ when(relationRow.getModType()).thenReturn((ModificationType) row[5]);
+ when(relationRow.getRationale()).thenReturn((String) row[6]);
+ when(relationRow.getLocalId()).thenReturn((Integer) row[7]);
+ when(relationRow.getTypeUuid()).thenReturn((Long) row[8]);
when(relationRow.getVersion()).thenReturn(version);
data.add(relationRow);
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactLoaderFactoryImplTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactLoaderFactoryImplTest.java
index e9fea67d74a..f98c1520797 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactLoaderFactoryImplTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactLoaderFactoryImplTest.java
@@ -48,7 +48,7 @@ public class ArtifactLoaderFactoryImplTest {
@Mock private DataLoaderFactory dataLoaderFactory;
@Mock private ArtifactBuilderFactory builderFactory;
- @Mock private SessionContext sessionContext;
+ @Mock private SessionContext session;
@Mock private QueryContext queryContext;
@Mock private DataLoader dbLoader;
@Mock private ArtifactBuilder builder;
@@ -61,23 +61,25 @@ public class ArtifactLoaderFactoryImplTest {
private final IOseeBranch branch = CoreBranches.COMMON;
private ArtifactLoaderFactory factory;
private List<ArtifactReadable> artifacts;
+ private String sessionId;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
factory = new ArtifactLoaderFactoryImpl(dataLoaderFactory, builderFactory);
artifacts = Arrays.asList(art1, art2);
+
+ sessionId = GUID.create();
+ when(session.getSessionId()).thenReturn(sessionId);
}
@Test
public void testLoadArtifactIdsAndMethodCalls() throws OseeCoreException {
int[] ids = new int[] {1, 2, 3, 4, 5};
- String sessionId = GUID.create();
- when(sessionContext.getSessionId()).thenReturn(sessionId);
when(dataLoaderFactory.fromBranchAndArtifactIds(sessionId, branch, ids)).thenReturn(dbLoader);
- ArtifactLoader loader = factory.fromBranchAndArtifactIds(sessionContext, branch, ids);
+ ArtifactLoader loader = factory.fromBranchAndArtifactIds(session, branch, ids);
verify(dataLoaderFactory).fromBranchAndArtifactIds(sessionId, branch, ids);
loader.includeDeleted();
@@ -115,11 +117,9 @@ public class ArtifactLoaderFactoryImplTest {
public void testLoad() throws OseeCoreException {
List<Integer> ids = Arrays.asList(1, 2, 3, 4, 5);
- String sessionId = GUID.create();
- when(sessionContext.getSessionId()).thenReturn(sessionId);
when(dataLoaderFactory.fromBranchAndArtifactIds(sessionId, branch, ids)).thenReturn(dbLoader);
- ArtifactLoader loader = factory.fromBranchAndArtifactIds(sessionContext, branch, ids);
+ ArtifactLoader loader = factory.fromBranchAndArtifactIds(session, branch, ids);
verify(dataLoaderFactory).fromBranchAndArtifactIds(sessionId, branch, ids);
when(builderFactory.createArtifactBuilder()).thenReturn(builder);
@@ -134,11 +134,9 @@ public class ArtifactLoaderFactoryImplTest {
public void testGetResults() throws OseeCoreException {
int[] ids = new int[] {1, 2, 3, 4, 5};
- String sessionId = GUID.create();
- when(sessionContext.getSessionId()).thenReturn(sessionId);
when(dataLoaderFactory.fromBranchAndArtifactIds(sessionId, branch, ids)).thenReturn(dbLoader);
- ArtifactLoader loader = factory.fromBranchAndArtifactIds(sessionContext, branch, ids);
+ ArtifactLoader loader = factory.fromBranchAndArtifactIds(session, branch, ids);
verify(dataLoaderFactory).fromBranchAndArtifactIds(sessionId, branch, ids);
when(builderFactory.createArtifactBuilder()).thenReturn(builder);
@@ -152,11 +150,9 @@ public class ArtifactLoaderFactoryImplTest {
@Test
public void testQueryContext() throws OseeCoreException {
- String sessionId = GUID.create();
- when(sessionContext.getSessionId()).thenReturn(sessionId);
when(dataLoaderFactory.fromQueryContext(queryContext)).thenReturn(dbLoader);
- ArtifactLoader loader = factory.fromQueryContext(sessionContext, queryContext);
+ ArtifactLoader loader = factory.fromQueryContext(session, queryContext);
verify(dataLoaderFactory).fromQueryContext(queryContext);
when(builderFactory.createArtifactBuilder()).thenReturn(builder);
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/CsvReader.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/CsvReader.java
deleted file mode 100644
index 7540fdc22bf..00000000000
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/CsvReader.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * 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:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.orcs.core.internal.loader;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-/**
- * @author Andrew M. Finkbeiner
- */
-public class CsvReader {
-
- private final InputStream inputStream;
- private final CsvRowHandler rowHandler;
-
- public CsvReader(InputStream inputStream, CsvRowHandler rowHandler) {
- this.inputStream = inputStream;
- this.rowHandler = rowHandler;
- }
-
- public void readFile() throws IOException {
- BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
- String line;
- while ((line = reader.readLine()) != null) {
- line = line.trim();
- if (!line.startsWith("#")) {
- String[] values = line.split(",");
- rowHandler.onRow(values);
- }
- }
- }
-
-}
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/CsvRowHandler.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/CsvRowHandler.java
deleted file mode 100644
index 1bc60fdcfc5..00000000000
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/CsvRowHandler.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * 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:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.orcs.core.internal.loader;
-
-/**
- * @author Andrew M. Finkbeiner
- */
-public interface CsvRowHandler {
-
- void onRow(String... row);
-
-}
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/data.csv b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/data.csv
deleted file mode 100644
index bbeff613a93..00000000000
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/data.csv
+++ /dev/null
@@ -1,24 +0,0 @@
- #ArtIdA,ArtIdB,BranchId,GammaId,ModType,Rationale,RelationId,RelationTypeId
-1,1,2,1,1,NEW,yay,1,1
-1,1,3,1,1,NEW,yay,2,1
-1,1,4,1,1,NEW,yay,3,1
-1,1,5,1,1,NEW,yay,4,1
-1,1,6,1,1,NEW,yay,5,1
-1,1,7,1,1,NEW,yay,6,1
-1,1,8,1,1,NEW,yay,7,1
-1,1,9,1,1,NEW,yay,8,1
-1,1,10,1,1,NEW,yay,9,1
-3,3,11,1,1,NEW,yay,10,1
-3,1,3,1,1,NEW,yay,10,1
-3,3,12,1,1,NEW,yay,11,1
-3,3,13,1,1,NEW,yay,12,1
-3,3,14,1,1,NEW,yay,13,1
-3,3,15,1,1,NEW,yay,14,1
-3,3,16,1,1,NEW,yay,15,1
-4,4,17,1,1,NEW,yay,16,1
-4,4,18,1,1,NEW,yay,17,1
-4,4,19,1,1,NEW,yay,18,1
-4,4,20,1,1,NEW,yay,19,1
-4,4,21,1,1,NEW,yay,20,1
-4,4,22,1,1,NEW,yay,21,1
-4,4,2,1,1,NEW,yay,21,1 \ No newline at end of file

Back to the top