Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarvin Mueller2016-10-25 08:22:27 -0400
committerMarvin Mueller2016-10-31 09:11:46 -0400
commit1cfaa13dddde2ddcb53a4fdce4bda01c39e28ac0 (patch)
tree5069831d938e7afe1de833e5053cabbfd5abe700
parentc3e45430100a463048b9a882484d0d3e0df05f77 (diff)
downloadorg.eclipse.jubula.core-1cfaa13dddde2ddcb53a4fdce4bda01c39e28ac0.tar.gz
org.eclipse.jubula.core-1cfaa13dddde2ddcb53a4fdce4bda01c39e28ac0.tar.xz
org.eclipse.jubula.core-1cfaa13dddde2ddcb53a4fdce4bda01c39e28ac0.zip
Fix for Bug 506450
Added exporting and importing of commentPO to the json model Change-Id: Id83d62ee1eb7549a5c6b0adc1f51c7faceedf05e
-rw-r--r--org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/JsonExporter.java17
-rw-r--r--org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/JsonImporter.java86
-rw-r--r--org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/JsonStorage.java1
-rw-r--r--org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/dto/CommentDTO.java36
-rw-r--r--org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/dto/NodeDTO.java1
-rw-r--r--org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/dto/TestCaseDTO.java3
-rw-r--r--org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/dto/TestJobDTO.java13
-rw-r--r--org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/dto/TestSuiteDTO.java12
8 files changed, 133 insertions, 36 deletions
diff --git a/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/JsonExporter.java b/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/JsonExporter.java
index 8dfac351f..ca847ff1c 100644
--- a/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/JsonExporter.java
+++ b/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/JsonExporter.java
@@ -28,6 +28,7 @@ import org.eclipse.jubula.client.archive.dto.AutDTO;
import org.eclipse.jubula.client.archive.dto.CapDTO;
import org.eclipse.jubula.client.archive.dto.CategoryDTO;
import org.eclipse.jubula.client.archive.dto.CheckConfigurationDTO;
+import org.eclipse.jubula.client.archive.dto.CommentDTO;
import org.eclipse.jubula.client.archive.dto.ComponentNameDTO;
import org.eclipse.jubula.client.archive.dto.ComponentNamesPairDTO;
import org.eclipse.jubula.client.archive.dto.DataRowDTO;
@@ -68,6 +69,7 @@ import org.eclipse.jubula.client.core.model.ICapParamDescriptionPO;
import org.eclipse.jubula.client.core.model.ICategoryPO;
import org.eclipse.jubula.client.core.model.ICheckConfContPO;
import org.eclipse.jubula.client.core.model.ICheckConfPO;
+import org.eclipse.jubula.client.core.model.ICommentPO;
import org.eclipse.jubula.client.core.model.ICompIdentifierPO;
import org.eclipse.jubula.client.core.model.ICompNamesPairPO;
import org.eclipse.jubula.client.core.model.IComponentNamePO;
@@ -618,6 +620,10 @@ public class JsonExporter {
RefTestCaseDTO refTestCaseDTO = new RefTestCaseDTO(tcPO);
fillRefTestCase(refTestCaseDTO, tcPO);
tcDTO.addTestStep(refTestCaseDTO);
+ } else if (o instanceof ICommentPO) {
+ ICommentPO commentPO = (ICommentPO) o;
+ CommentDTO commentDTO = new CommentDTO(commentPO);
+ tcDTO.addTestStep(commentDTO);
}
}
@@ -820,8 +826,13 @@ public class JsonExporter {
IExecTestCasePO tc = (IExecTestCasePO)o;
RefTestCaseDTO rtcDTO = new RefTestCaseDTO(tc);
fillRefTestCase(rtcDTO, tc);
- tsDTO.addUsedTestcase(rtcDTO);
+ tsDTO.addUsedTestCase(rtcDTO);
+ } else if (o instanceof ICommentPO) {
+ ICommentPO commentPO = (ICommentPO) o;
+ CommentDTO commentDTO = new CommentDTO(commentPO);
+ tsDTO.addUsedTestCase(commentDTO);
}
+
}
for (Object o : po.getDefaultEventHandler().keySet()) {
String eventType = (String)o;
@@ -848,7 +859,7 @@ public class JsonExporter {
* @param tj test job object
*/
private void fillTestJob(TestJobDTO tjDTO, ITestJobPO tj) {
- for (Object child : tj.getUnmodifiableNodeList()) {
+ for (INodePO child : tj.getUnmodifiableNodeList()) {
if (child instanceof IRefTestSuitePO) {
IRefTestSuitePO rts = (IRefTestSuitePO)child;
RefTestSuiteDTO rtsDTO = new RefTestSuiteDTO(rts);
@@ -857,6 +868,8 @@ public class JsonExporter {
rtsDTO.setTsUuid(rts.getTestSuiteGuid());
rtsDTO.setAutId(rts.getTestSuiteAutID());
tjDTO.addRefTestSuite(rtsDTO);
+ } else if (child instanceof ICommentPO) {
+ tjDTO.addComment(new CommentDTO((ICommentPO) child));
}
}
}
diff --git a/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/JsonImporter.java b/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/JsonImporter.java
index a3432bc83..51ed1b37a 100644
--- a/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/JsonImporter.java
+++ b/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/JsonImporter.java
@@ -32,6 +32,7 @@ import org.eclipse.jubula.client.archive.dto.CategoryDTO;
import org.eclipse.jubula.client.archive.dto.CheckActivatedContextDTO;
import org.eclipse.jubula.client.archive.dto.CheckAttributeDTO;
import org.eclipse.jubula.client.archive.dto.CheckConfigurationDTO;
+import org.eclipse.jubula.client.archive.dto.CommentDTO;
import org.eclipse.jubula.client.archive.dto.ComponentNameDTO;
import org.eclipse.jubula.client.archive.dto.ComponentNamesPairDTO;
import org.eclipse.jubula.client.archive.dto.DataRowDTO;
@@ -77,6 +78,7 @@ import org.eclipse.jubula.client.core.model.ICapPO;
import org.eclipse.jubula.client.core.model.ICategoryPO;
import org.eclipse.jubula.client.core.model.ICheckConfContPO;
import org.eclipse.jubula.client.core.model.ICheckConfPO;
+import org.eclipse.jubula.client.core.model.ICommentPO;
import org.eclipse.jubula.client.core.model.ICompNamesPairPO;
import org.eclipse.jubula.client.core.model.IComponentNamePO;
import org.eclipse.jubula.client.core.model.IEventExecTestCasePO;
@@ -393,6 +395,9 @@ public class JsonImporter {
} else if (stepDto instanceof RefTestCaseDTO) {
tc.addNode(createExecTestCase(
proj, (RefTestCaseDTO)stepDto, assignNewGuid));
+ } else if (stepDto instanceof CommentDTO) {
+ tc.addNode(createComment((CommentDTO) stepDto,
+ assignNewGuid));
}
}
for (EventTestCaseDTO evTcDto : dto.getEventTestcases()) {
@@ -461,6 +466,20 @@ public class JsonImporter {
}
/**
+ *
+ * @param dto the DTO to
+ * @param assignNewUuid if there should be a new Uuid
+ * @return a {@link ICommentPO}
+ */
+ private ICommentPO createComment(CommentDTO dto,
+ boolean assignNewUuid) {
+ if (dto.getUuid() != null && !assignNewUuid) {
+ return NodeMaker.createCommentPO(dto.getName(), dto.getUuid());
+ }
+ return NodeMaker.createCommentPO(dto.getName());
+ }
+
+ /**
* @param componentType component type name
* @return true if the component has a default mapping and therefore has no
* component name
@@ -1202,7 +1221,7 @@ public class JsonImporter {
*/
private IExecPersistable createTestJob(TestJobDTO dto,
boolean assignNewGuid) throws InvalidDataException {
-
+
ITestJobPO tj;
if (dto.getUuid() != null && !assignNewGuid) {
tj = NodeMaker.createTestJobPO(dto.getName(), dto.getUuid());
@@ -1213,31 +1232,40 @@ public class JsonImporter {
tj.setDescription(dto.getDescription());
tj.setTaskId(dto.getTaskId());
fillTrackedChangesInformation(tj, dto);
-
- for (RefTestSuiteDTO dtoRts : dto.getRefTestSuites()) {
- IRefTestSuitePO rts;
- if (assignNewGuid) {
- // Only Test Suites from the same project can be referenced,
- // and all Test Suites for this Project have already been
- // initialized (so they have already been entered into the
- // old to new GUID map). This is why we can simply directly use
- // the old to new GUID map.
- String testSuiteGuid = m_oldToNewGuids.get(dtoRts.getTsUuid());
- if (testSuiteGuid == null) {
- throw new InvalidDataException(
- "Test Suite Reference: No new GUID found for Test Suite with old GUID: " + dtoRts.getTsUuid(), //$NON-NLS-1$
- MessageIDs.E_IMPORT_PROJECT_XML_FAILED);
- }
- rts = NodeMaker.createRefTestSuitePO(dtoRts.getName(),
- testSuiteGuid, dtoRts.getAutId());
- } else {
- rts = NodeMaker.createRefTestSuitePO(dtoRts.getName(), dtoRts
- .getUuid(), dtoRts.getTsUuid(), dtoRts.getAutId());
+ for (NodeDTO dtoRefs : dto.getRefTestSuites()) {
+ if (dtoRefs instanceof RefTestSuiteDTO) {
+ RefTestSuiteDTO dtoRts = (RefTestSuiteDTO) dtoRefs;
+ IRefTestSuitePO rts;
+ if (assignNewGuid) {
+ // Only Test Suites from the same project can be referenced,
+ // and all Test Suites for this Project have already been
+ // initialized (so they have already been entered into the
+ // old to new GUID map). This is why we can simply directly
+ // use
+ // the old to new GUID map.
+ String testSuiteGuid =
+ m_oldToNewGuids.get(dtoRts.getTsUuid());
+ if (testSuiteGuid == null) {
+ throw new InvalidDataException(
+ "Test Suite Reference: No new GUID found for Test Suite with old GUID: " //$NON-NLS-1$
+ + dtoRts.getTsUuid(),
+ MessageIDs.E_IMPORT_PROJECT_XML_FAILED);
+ }
+ rts = NodeMaker.createRefTestSuitePO(dtoRts.getName(),
+ testSuiteGuid, dtoRts.getAutId());
+ } else {
+ rts = NodeMaker.createRefTestSuitePO(dtoRts.getName(),
+ dtoRts.getUuid(), dtoRts.getTsUuid(),
+ dtoRts.getAutId());
+
+ }
+ rts.setComment(dtoRts.getComment());
+ rts.setDescription(dtoRts.getDescription());
+ tj.addNode(rts);
+ } else if (dtoRefs instanceof CommentDTO) {
+ tj.addNode(createComment((CommentDTO) dtoRefs, assignNewGuid));
}
- rts.setComment(dtoRts.getComment());
- rts.setDescription(dtoRts.getDescription());
- tj.addNode(rts);
}
return tj;
}
@@ -1317,8 +1345,14 @@ public class JsonImporter {
if (dto.getSelectedAut() != null) {
ts.setAut(m_autRef.get(dto.getSelectedAut()));
}
- for (RefTestCaseDTO ref : dto.getUsedTestcases()) {
- ts.addNode(createExecTestCase(proj, ref, assignNewGuid));
+ for (NodeDTO ref : dto.getUsedTestCases()) {
+ if (ref instanceof RefTestCaseDTO) {
+ ts.addNode(createExecTestCase(proj, (RefTestCaseDTO) ref,
+ assignNewGuid));
+ }
+ if (ref instanceof CommentDTO) {
+ ts.addNode(createComment((CommentDTO) ref, assignNewGuid));
+ }
}
Map<String, Integer> defaultEventHandler =
diff --git a/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/JsonStorage.java b/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/JsonStorage.java
index e294258aa..71516ec02 100644
--- a/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/JsonStorage.java
+++ b/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/JsonStorage.java
@@ -318,6 +318,7 @@ public class JsonStorage {
importer.initTestResultSummaries(subMonitor.newChild(1),
summaryDTOs, projectPO);
} catch (IOException e) {
+ log.warn("error during import", e); //$NON-NLS-1$
// If the operation has been canceled, then this is just
// a result of canceling the IO.
if (!monitor.isCanceled()) {
diff --git a/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/dto/CommentDTO.java b/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/dto/CommentDTO.java
new file mode 100644
index 000000000..df236a044
--- /dev/null
+++ b/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/dto/CommentDTO.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2016 BREDEX GmbH.
+ * 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:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+/**
+ *
+ */
+package org.eclipse.jubula.client.archive.dto;
+
+import org.eclipse.jubula.client.core.model.ICommentPO;
+
+/**
+ * @author BREDEX GmbH
+ *
+ */
+public class CommentDTO extends NodeDTO {
+
+ /** needed because JSON mapping */
+ public CommentDTO() {
+
+ }
+ /**
+ *
+ * @param node the po to make to a DTO
+ */
+ public CommentDTO(ICommentPO node) {
+ super(node);
+ }
+
+}
diff --git a/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/dto/NodeDTO.java b/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/dto/NodeDTO.java
index a4421e420..13482e11a 100644
--- a/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/dto/NodeDTO.java
+++ b/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/dto/NodeDTO.java
@@ -29,6 +29,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
property = "type")
@JsonSubTypes({
@Type(value = CategoryDTO.class, name = "cat"),
+ @Type(value = CommentDTO.class, name = "com"),
@Type(value = ExecCategoryDTO.class, name = "ecat"),
@Type(value = ParameterDTO.class, name = "par"),
@Type(value = ProjectDTO.class, name = "pro"),
diff --git a/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/dto/TestCaseDTO.java b/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/dto/TestCaseDTO.java
index 98ba69733..c006358a5 100644
--- a/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/dto/TestCaseDTO.java
+++ b/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/dto/TestCaseDTO.java
@@ -54,7 +54,8 @@ public class TestCaseDTO extends ParameterDTO {
*/
public void addTestStep(NodeDTO testStep) {
if (!(testStep instanceof RefTestCaseDTO
- || testStep instanceof CapDTO)) {
+ || testStep instanceof CapDTO
+ || testStep instanceof CommentDTO)) {
throw new IllegalArgumentException();
}
this.m_testSteps.add(testStep);
diff --git a/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/dto/TestJobDTO.java b/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/dto/TestJobDTO.java
index abcdf0ca1..afc7b69e8 100644
--- a/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/dto/TestJobDTO.java
+++ b/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/dto/TestJobDTO.java
@@ -22,8 +22,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
*/
public class TestJobDTO extends NodeDTO {
/** */
- private List<RefTestSuiteDTO> m_refTestSuites =
- new ArrayList<RefTestSuiteDTO>();
+ private List<NodeDTO> m_refTestSuites =
+ new ArrayList<NodeDTO>();
/** needed because JSON mapping */
@@ -42,12 +42,19 @@ public class TestJobDTO extends NodeDTO {
public void addRefTestSuite(RefTestSuiteDTO rtsDTO) {
m_refTestSuites.add(rtsDTO);
}
+
+ /**
+ * @param commentDTO
+ */
+ public void addComment(CommentDTO commentDTO) {
+ m_refTestSuites.add(commentDTO);
+ }
/**
* @return refTestSuites
*/
@JsonProperty("refTestSuites")
- public List<RefTestSuiteDTO> getRefTestSuites() {
+ public List<NodeDTO> getRefTestSuites() {
return m_refTestSuites;
}
}
diff --git a/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/dto/TestSuiteDTO.java b/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/dto/TestSuiteDTO.java
index b6876ab07..3dd75ba84 100644
--- a/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/dto/TestSuiteDTO.java
+++ b/org.eclipse.jubula.client.archive/src/org/eclipse/jubula/client/archive/dto/TestSuiteDTO.java
@@ -27,8 +27,8 @@ public class TestSuiteDTO extends NodeDTO {
/** */
private int m_stepDelay = 0;
/** */
- private List<RefTestCaseDTO> m_usedTestcases =
- new ArrayList<RefTestCaseDTO>();
+ private List<NodeDTO> m_usedTestcases =
+ new ArrayList<NodeDTO>();
/** */
private List<DefaultEventHandlerDTO> m_eventHandlers =
new ArrayList<DefaultEventHandlerDTO>(4);
@@ -80,14 +80,18 @@ public class TestSuiteDTO extends NodeDTO {
* @return usedTestcase
*/
@JsonProperty("usedTestcase")
- public List<RefTestCaseDTO> getUsedTestcases() {
+ public List<NodeDTO> getUsedTestCases() {
return m_usedTestcases;
}
/**
* @param usedTestcase
*/
- public void addUsedTestcase(RefTestCaseDTO usedTestcase) {
+ public void addUsedTestCase(NodeDTO usedTestcase) {
+ if (!(usedTestcase instanceof RefTestCaseDTO
+ || usedTestcase instanceof CommentDTO)) {
+ throw new IllegalArgumentException();
+ }
this.m_usedTestcases.add(usedTestcase);
}

Back to the top