From ab88af3cdd2a8c7a7701c379a9de5d0cbdc2dbb2 Mon Sep 17 00:00:00 2001 From: cramakri <cramakri> Date: Mon, 30 Jul 2012 09:41:23 +0000 Subject: [PATCH] BIS-38 SP-204 : Improved messages. SVN: 26279 --- ...nfoDBConsistencyCheckProcessingPlugin.java | 48 +++++++++++++++---- ...BConsistencyCheckProcessingPluginTest.java | 46 ++++++++++++++---- 2 files changed, 75 insertions(+), 19 deletions(-) diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/DataSetAndPathInfoDBConsistencyCheckProcessingPlugin.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/DataSetAndPathInfoDBConsistencyCheckProcessingPlugin.java index 0a0bb09647f..b388cf49559 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/DataSetAndPathInfoDBConsistencyCheckProcessingPlugin.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/DataSetAndPathInfoDBConsistencyCheckProcessingPlugin.java @@ -176,8 +176,8 @@ public class DataSetAndPathInfoDBConsistencyCheckProcessingPlugin implements IPr // report a difference if node paths do not match if (fileNode.getRelativePath().equals(pathInfoNode.getRelativePath()) == false) { - differences.add(new NodeExistenceDifference(fileNode.getRelativePath(), true)); - differences.add(new NodeExistenceDifference(pathInfoNode.getRelativePath(), false)); + differences.add(new NodeChildrenDifference(fileNode.getRelativePath(), true)); + differences.add(new NodeChildrenDifference(pathInfoNode.getRelativePath(), false)); } if (fileNode.isDirectory() && pathInfoNode.isDirectory()) @@ -194,11 +194,11 @@ public class DataSetAndPathInfoDBConsistencyCheckProcessingPlugin implements IPr // report differences for nodes that exist only in one place for (IHierarchicalContentNode uncommonNode : children.getFileUncommonNodes()) { - differences.add(new NodeExistenceDifference(uncommonNode.getRelativePath(), true)); + differences.add(new NodeChildrenDifference(uncommonNode.getRelativePath(), true)); } for (IHierarchicalContentNode uncommonNode : children.getPathInfoUncommonNodes()) { - differences.add(new NodeExistenceDifference(uncommonNode.getRelativePath(), false)); + differences.add(new NodeChildrenDifference(uncommonNode.getRelativePath(), false)); } } else if (fileNode.isDirectory() == false && pathInfoNode.isDirectory() == false) @@ -366,10 +366,10 @@ public class DataSetAndPathInfoDBConsistencyCheckProcessingPlugin implements IPr { if (existsInFS) { - return "exists in the file system but doesn't exist in the path info database"; + return "exists in the file system but does not exist in the path info database"; } else { - return "exists in the path info database but doesn't exist in the file system"; + return "exists in the path info database but does not exist in the file system"; } } @@ -391,12 +391,42 @@ public class DataSetAndPathInfoDBConsistencyCheckProcessingPlugin implements IPr { if (existsInFS) { - return "'" + getPath() - + "' exists on the file system but doesn't exist in the path info database"; + return "'" + + getPath() + + "' exists on the file system but does not exist in the path info database"; } else + { + return "'" + + getPath() + + "' exists in the path info database but does not exist on the file system"; + } + } + + } + + private class NodeChildrenDifference extends Difference + { + + private boolean existsInFS; + + public NodeChildrenDifference(String path, boolean existsInFS) + { + super(path); + this.existsInFS = existsInFS; + } + + @Override + public String getDescription() + { + if (existsInFS) { return "'" + getPath() - + "' exists in the path info database but doesn't exist on the file system"; + + "' is on the file system but is not referenced in the path info database"; + } else + { + return "'" + + getPath() + + "' is referenced in the path info database but does not exist on the file system"; } } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/DataSetAndPathInfoDBConsistencyCheckProcessingPluginTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/DataSetAndPathInfoDBConsistencyCheckProcessingPluginTest.java index 257b34078ce..40e47666f00 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/DataSetAndPathInfoDBConsistencyCheckProcessingPluginTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/DataSetAndPathInfoDBConsistencyCheckProcessingPluginTest.java @@ -90,7 +90,7 @@ public class DataSetAndPathInfoDBConsistencyCheckProcessingPluginTest extends // add more when necessary public enum FailurePoint { - ROOT_NODE_EXISTS, FILE_LENGTH; + ROOT_NODE_EXISTS, ROOT_NODE_PATH, FILE_LENGTH; } } @@ -176,6 +176,10 @@ public class DataSetAndPathInfoDBConsistencyCheckProcessingPluginTest extends testCase.failurePoints.add(TestCaseParameters.FailurePoint.ROOT_NODE_EXISTS); testCases.add(testCase); + testCase = new TestCaseParameters("Root node path"); + testCase.failurePoints.add(TestCaseParameters.FailurePoint.ROOT_NODE_PATH); + testCases.add(testCase); + testCase = new TestCaseParameters("File length discrepency"); testCase.failurePoints.add(TestCaseParameters.FailurePoint.FILE_LENGTH); testCases.add(testCase); @@ -243,8 +247,17 @@ public class DataSetAndPathInfoDBConsistencyCheckProcessingPluginTest extends + "Differences found:\n\n" + "Data set ds-1:\n" + "- 'targets/unit-test-wd/ch.systemsx.cisd.openbis.dss.generic.server.plugins.standard.DataSetAndPathInfoDBConsistencyCheckProcessingPluginTest' " - + "exists in the path info database but doesn't exist on the file system\n\n"; + + "exists in the path info database but does not exist on the file system\n\n"; + } else if (parameters.failurePoints + .contains(TestCaseParameters.FailurePoint.ROOT_NODE_PATH)) + { + body = + "Data sets checked:\n\nds-1\n\n" + + "Differences found:\n\n" + + "Data set ds-1:\n" + + "- 'different' is referenced in the path info database but does not exist on the file system\n" + + "- 'targets/unit-test-wd/ch.systemsx.cisd.openbis.dss.generic.server.plugins.standard.DataSetAndPathInfoDBConsistencyCheckProcessingPluginTest' is on the file system but is not referenced in the path info database\n\n"; } else { body = "Data sets checked:\n\nds-1\n\nDifferences found:\n\nNone"; @@ -335,14 +348,28 @@ public class DataSetAndPathInfoDBConsistencyCheckProcessingPluginTest extends protected void getRelativePath() { - if (false == parameters.failurePoints + if (parameters.failurePoints .contains(TestCaseParameters.FailurePoint.ROOT_NODE_EXISTS)) { - oneOf(fileRootNode).getRelativePath(); + oneOf(pathInfoRootNode).getRelativePath(); will(returnValue(workingDirectory.getPath())); + return; } + if (parameters.failurePoints + .contains(TestCaseParameters.FailurePoint.ROOT_NODE_PATH)) + { + exactly(2).of(fileRootNode).getRelativePath(); + will(returnValue(workingDirectory.getPath())); + exactly(2).of(pathInfoRootNode).getRelativePath(); + will(returnValue("different")); + return; + } + + oneOf(fileRootNode).getRelativePath(); + will(returnValue(workingDirectory.getPath())); oneOf(pathInfoRootNode).getRelativePath(); will(returnValue(workingDirectory.getPath())); + } protected void rootNodeExists() @@ -354,13 +381,12 @@ public class DataSetAndPathInfoDBConsistencyCheckProcessingPluginTest extends will(returnValue(false)); oneOf(pathInfoRootNode).exists(); will(returnValue(true)); - } else - { - oneOf(fileRootNode).exists(); - will(returnValue(true)); - oneOf(pathInfoRootNode).exists(); - will(returnValue(true)); + return; } + oneOf(fileRootNode).exists(); + will(returnValue(true)); + oneOf(pathInfoRootNode).exists(); + will(returnValue(true)); } protected void getRootNode() -- GitLab