[UPDATE]
- modifies importFiles-method in AbstractMarshaller.java to return boolean for easier test evaluation - reduces import tests to a single xml file for easier problem finding - modifies insertIntoDb method overriden by RoleMembershipMarshaller git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4554 8810af33-2d31-482b-a856-94f89814c4dfccm-docs
parent
6ec7ed2ac1
commit
aa1b321a0b
|
|
@ -174,9 +174,10 @@ public abstract class AbstractMarshaller<P extends Portable> {
|
||||||
* of the list represents an object of the file. Then retrieves each object
|
* of the list represents an object of the file. Then retrieves each object
|
||||||
* from the corresponding string in the list.
|
* from the corresponding string in the list.
|
||||||
*
|
*
|
||||||
* @return List of imported objects.
|
* @return If error occurs true, otherwise false.
|
||||||
*/
|
*/
|
||||||
public List<P> importFile() {
|
public boolean importFile() {
|
||||||
|
boolean error = false;
|
||||||
File file = new File(filename);
|
File file = new File(filename);
|
||||||
|
|
||||||
List<String> lines = null;
|
List<String> lines = null;
|
||||||
|
|
@ -186,6 +187,7 @@ public abstract class AbstractMarshaller<P extends Portable> {
|
||||||
LOGGER.error("Unable to read lines of the file with " +
|
LOGGER.error("Unable to read lines of the file with " +
|
||||||
"name {}.", file.getName());
|
"name {}.", file.getName());
|
||||||
LOGGER.error(e);
|
LOGGER.error(e);
|
||||||
|
error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<P> objects = new ArrayList<>();
|
List<P> objects = new ArrayList<>();
|
||||||
|
|
@ -201,6 +203,7 @@ public abstract class AbstractMarshaller<P extends Portable> {
|
||||||
LOGGER.error("Unable to read objects " +
|
LOGGER.error("Unable to read objects " +
|
||||||
"from XML line:\n \"{}\"", line);
|
"from XML line:\n \"{}\"", line);
|
||||||
LOGGER.error(e);
|
LOGGER.error(e);
|
||||||
|
error = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -214,10 +217,11 @@ public abstract class AbstractMarshaller<P extends Portable> {
|
||||||
} else {
|
} else {
|
||||||
emptyObjects+=1;
|
emptyObjects+=1;
|
||||||
LOGGER.info("Count of empty objects: {}", emptyObjects);
|
LOGGER.info("Count of empty objects: {}", emptyObjects);
|
||||||
|
error = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return objects;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -45,10 +45,10 @@ public class RoleMembershipMarshaller extends AbstractMarshaller<RoleMembership>
|
||||||
@Override
|
@Override
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
protected void insertIntoDb(RoleMembership portableObject) {
|
protected void insertIntoDb(RoleMembership portableObject) {
|
||||||
if (portableObject.getMembershipId() == 0) {
|
// if (portableObject.getMembershipId() == 0) {
|
||||||
entityManager.persist(portableObject);
|
entityManager.persist(portableObject);
|
||||||
} else {
|
// } else {
|
||||||
entityManager.merge(portableObject);
|
// entityManager.merge(portableObject);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ import org.jboss.shrinkwrap.api.asset.EmptyAsset;
|
||||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
@ -107,6 +108,8 @@ public class CoreDataImportTest {
|
||||||
.class.getPackage())
|
.class.getPackage())
|
||||||
.addPackage(org.libreccm.jpa.EntityManagerProducer
|
.addPackage(org.libreccm.jpa.EntityManagerProducer
|
||||||
.class.getPackage())
|
.class.getPackage())
|
||||||
|
.addClass(com.arsdigita.util.UncheckedWrapperException
|
||||||
|
.class)
|
||||||
.addAsLibraries(getModuleDependencies())
|
.addAsLibraries(getModuleDependencies())
|
||||||
.addAsResource("test-persistence.xml",
|
.addAsResource("test-persistence.xml",
|
||||||
"META-INF/persistence.xml")
|
"META-INF/persistence.xml")
|
||||||
|
|
@ -127,70 +130,73 @@ public class CoreDataImportTest {
|
||||||
@Test
|
@Test
|
||||||
@InSequence(105)
|
@InSequence(105)
|
||||||
public void categoriesShouldBeImported() {
|
public void categoriesShouldBeImported() {
|
||||||
importHelper.importRoleMemberships();
|
Assert.assertFalse(importHelper.importRoleMemberships());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
//@Test
|
||||||
@InSequence(110)
|
@InSequence(110)
|
||||||
public void categorizationsShouldBeImported() {
|
public void categorizationsShouldBeImported() {
|
||||||
importHelper.importGroupMemberships();
|
importHelper.importGroupMemberships();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
//@Test
|
||||||
@InSequence(115)
|
@InSequence(115)
|
||||||
public void usersShouldBeImported() {
|
public void usersShouldBeImported() {
|
||||||
importHelper.importGroups();
|
importHelper.importGroups();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
//@Test
|
||||||
@InSequence(120)
|
@InSequence(120)
|
||||||
public void groupsShouldBeImported() {
|
public void groupsShouldBeImported() {
|
||||||
importHelper.importUsers();
|
importHelper.importUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
//@Test
|
||||||
@InSequence(125)
|
@InSequence(125)
|
||||||
public void groupMembershipsShouldBeImported() {
|
public void groupMembershipsShouldBeImported() {
|
||||||
importHelper.importTaskAssignments();
|
importHelper.importTaskAssignments();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
//@Test
|
||||||
@InSequence(130)
|
@InSequence(130)
|
||||||
public void rolesShouldBeImported() {
|
public void rolesShouldBeImported() {
|
||||||
importHelper.importAssignableTasks();
|
importHelper.importAssignableTasks();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
//@Test
|
||||||
@InSequence(135)
|
@InSequence(135)
|
||||||
public void roleMembershipsShouldBeImported() {
|
public void roleMembershipsShouldBeImported() {
|
||||||
importHelper.importWorkflowTemplates();
|
importHelper.importWorkflowTemplates();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
//@Test
|
||||||
@InSequence(140)
|
@InSequence(140)
|
||||||
public void workflowTemplatesShouldBeImported() {
|
public void workflowTemplatesShouldBeImported() {
|
||||||
importHelper.importWorkflows();
|
importHelper.importWorkflows();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
|
|
||||||
|
|
||||||
|
//@Test
|
||||||
@InSequence(145)
|
@InSequence(145)
|
||||||
public void workflowsShouldBeImported() {
|
public void workflowsShouldBeImported() {
|
||||||
importHelper.importCategorizations();
|
importHelper.importCategorizations();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
//@Test
|
||||||
@InSequence(150)
|
@InSequence(150)
|
||||||
public void assignableTasksShouldBeImported() {
|
public void assignableTasksShouldBeImported() {
|
||||||
importHelper.importPermissions();
|
importHelper.importPermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
//@Test
|
||||||
@InSequence(155)
|
@InSequence(155)
|
||||||
public void taskAssignmentsShouldBeImported() {
|
public void taskAssignmentsShouldBeImported() {
|
||||||
importHelper.importCategories();
|
importHelper.importCategories();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
//@Test
|
||||||
@InSequence(160)
|
@InSequence(160)
|
||||||
public void permissionsShouldBeImported() {
|
public void permissionsShouldBeImported() {
|
||||||
importHelper.importRoles();
|
importHelper.importRoles();
|
||||||
|
|
|
||||||
|
|
@ -55,8 +55,9 @@ import javax.inject.Inject;
|
||||||
*/
|
*/
|
||||||
@RequestScoped
|
@RequestScoped
|
||||||
class ImportHelper {
|
class ImportHelper {
|
||||||
private String pathName =
|
private String repoPath = "/home/tosmers/Svn/libreccm/";
|
||||||
"/home/jensp/pwi/libreccm/ccm/ccm_ng/ccm-core/src/test/resources/" +
|
//private String repoPath = "";
|
||||||
|
private String projectPath = "ccm_ng/ccm-core/src/test/resources/" +
|
||||||
"portation/trunk-iaw-exports";
|
"portation/trunk-iaw-exports";
|
||||||
private boolean indentation = false;
|
private boolean indentation = false;
|
||||||
|
|
||||||
|
|
@ -99,73 +100,73 @@ class ImportHelper {
|
||||||
|
|
||||||
|
|
||||||
void importCategories() {
|
void importCategories() {
|
||||||
categoryMarshaller.prepare(Format.XML, pathName,
|
categoryMarshaller.prepare(Format.XML, repoPath + projectPath,
|
||||||
"categories.xml", indentation);
|
"categories.xml", indentation);
|
||||||
categoryMarshaller.importFile();
|
categoryMarshaller.importFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void importCategorizations() {
|
void importCategorizations() {
|
||||||
categorizationMarshaller.prepare(Format.XML, pathName,
|
categorizationMarshaller.prepare(Format.XML, repoPath + projectPath,
|
||||||
"categorizations.xml", indentation);
|
"categorizations.xml", indentation);
|
||||||
categorizationMarshaller.importFile();
|
categorizationMarshaller.importFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void importUsers() {
|
void importUsers() {
|
||||||
userMarshaller.prepare(Format.XML, pathName,
|
userMarshaller.prepare(Format.XML, repoPath + projectPath,
|
||||||
"users.xml", indentation);
|
"users.xml", indentation);
|
||||||
userMarshaller.importFile();
|
userMarshaller.importFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void importGroups() {
|
void importGroups() {
|
||||||
groupMarshaller.prepare(Format.XML, pathName,
|
groupMarshaller.prepare(Format.XML, repoPath + projectPath,
|
||||||
"groups.xml", indentation);
|
"groups.xml", indentation);
|
||||||
groupMarshaller.importFile();
|
groupMarshaller.importFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void importGroupMemberships() {
|
void importGroupMemberships() {
|
||||||
groupMembershipMarshaller.prepare(Format.XML, pathName,
|
groupMembershipMarshaller.prepare(Format.XML, repoPath + projectPath,
|
||||||
"groupMemberships.xml", indentation);
|
"groupMemberships.xml", indentation);
|
||||||
groupMembershipMarshaller.importFile();
|
groupMembershipMarshaller.importFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void importRoles() {
|
void importRoles() {
|
||||||
roleMarshaller.prepare(Format.XML, pathName,
|
roleMarshaller.prepare(Format.XML, repoPath + projectPath,
|
||||||
"roles.xml", indentation);
|
"roles.xml", indentation);
|
||||||
roleMarshaller.importFile();
|
roleMarshaller.importFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void importRoleMemberships() {
|
boolean importRoleMemberships() {
|
||||||
roleMembershipMarshaller.prepare(Format.XML, pathName,
|
roleMembershipMarshaller.prepare(Format.XML, repoPath + projectPath,
|
||||||
"roleMemberships.xml", indentation);
|
"roleMemberships.xml", indentation);
|
||||||
roleMembershipMarshaller.importFile();
|
return roleMembershipMarshaller.importFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void importWorkflowTemplates() {
|
void importWorkflowTemplates() {
|
||||||
workflowTemplateMarshaller.prepare(Format.XML, pathName,
|
workflowTemplateMarshaller.prepare(Format.XML, repoPath + projectPath,
|
||||||
"workflowTemplates.xml", indentation);
|
"workflowTemplates.xml", indentation);
|
||||||
workflowTemplateMarshaller.importFile();
|
workflowTemplateMarshaller.importFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void importWorkflows() {
|
void importWorkflows() {
|
||||||
workflowMarshaller.prepare(Format.XML, pathName,
|
workflowMarshaller.prepare(Format.XML, repoPath + projectPath,
|
||||||
"workflows.xml", indentation);
|
"workflows.xml", indentation);
|
||||||
workflowMarshaller.importFile();
|
workflowMarshaller.importFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void importAssignableTasks() {
|
void importAssignableTasks() {
|
||||||
assignableTaskMarshaller.prepare(Format.XML, pathName,
|
assignableTaskMarshaller.prepare(Format.XML, repoPath + projectPath,
|
||||||
"assignableTasks.xml", indentation);
|
"assignableTasks.xml", indentation);
|
||||||
assignableTaskMarshaller.importFile();
|
assignableTaskMarshaller.importFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void importTaskAssignments() {
|
void importTaskAssignments() {
|
||||||
taskAssignmentMarshaller.prepare(Format.XML, pathName,
|
taskAssignmentMarshaller.prepare(Format.XML, repoPath + projectPath,
|
||||||
"taskAssignments.xml", indentation);
|
"taskAssignments.xml", indentation);
|
||||||
taskAssignmentMarshaller.importFile();
|
taskAssignmentMarshaller.importFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void importPermissions() {
|
void importPermissions() {
|
||||||
permissionMarshaller.prepare(Format.XML, pathName,
|
permissionMarshaller.prepare(Format.XML, repoPath + projectPath,
|
||||||
"permissions.xml", indentation);
|
"permissions.xml", indentation);
|
||||||
permissionMarshaller.importFile();
|
permissionMarshaller.importFile();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue