From b9b9cf6e4b5753f729caedcd76e04a368030e8b6 Mon Sep 17 00:00:00 2001 From: ribeaudc <ribeaudc> Date: Tue, 12 Aug 2008 19:34:19 +0000 Subject: [PATCH] [LMS-531] fix: - Database instance code is never empty in 'SampleWithOwner'. SVN: 7831 --- .../ch/systemsx/cisd/bds/SampleWithOwner.java | 15 ++++----------- .../ch/systemsx/cisd/bds/SampleWithOwnerTest.java | 9 +++------ 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/bds/source/java/ch/systemsx/cisd/bds/SampleWithOwner.java b/bds/source/java/ch/systemsx/cisd/bds/SampleWithOwner.java index bd6bd085a5d..118de2b1da8 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/SampleWithOwner.java +++ b/bds/source/java/ch/systemsx/cisd/bds/SampleWithOwner.java @@ -64,23 +64,16 @@ public final class SampleWithOwner extends Sample super(code, typeCode, typeDescription); assert groupCode != null : "Undefined group code."; assert databaseInstanceCode != null : "Undefined database instance code."; - assertOneNonEmpty(groupCode, databaseInstanceCode); + assertNonEmptyDatabaseInstanceCode(databaseInstanceCode); this.groupCode = groupCode; this.databaseInstanceCode = databaseInstanceCode; } - private final static void assertOneNonEmpty(final String groupCode, - final String databaseInstanceCode) + private final static void assertNonEmptyDatabaseInstanceCode(final String databaseInstanceCode) { - if (groupCode.length() == 0 && databaseInstanceCode.length() == 0) - { - throw new DataStructureException( - "Both, group code and database instance code, are empty."); - } - if (groupCode.length() > 0 && databaseInstanceCode.length() > 0) + if (databaseInstanceCode.length() == 0) { - throw new DataStructureException("At most one, the group code OR the database " - + "instance code, must be non empty."); + throw new DataStructureException("Empty database instance code."); } } diff --git a/bds/sourceTest/java/ch/systemsx/cisd/bds/SampleWithOwnerTest.java b/bds/sourceTest/java/ch/systemsx/cisd/bds/SampleWithOwnerTest.java index 086b59dd8d4..2b913a5c1c2 100644 --- a/bds/sourceTest/java/ch/systemsx/cisd/bds/SampleWithOwnerTest.java +++ b/bds/sourceTest/java/ch/systemsx/cisd/bds/SampleWithOwnerTest.java @@ -66,15 +66,12 @@ public final class SampleWithOwnerTest extends AbstractFileSystemTestCase } try { - new SampleWithOwner(CODE, TYPE_CODE, TYPE_DESCRIPTION, GROUP_CODE, - DATABASE_INSTANCE_CODE); + new SampleWithOwner(CODE, TYPE_CODE, TYPE_DESCRIPTION, GROUP_CODE, ""); fail(); } catch (final DataStructureException e) { // Nothing to do here. } - assertEquals(false, fail); - new SampleWithOwner(CODE, TYPE_CODE, TYPE_DESCRIPTION, GROUP_CODE, ""); } @DataProvider @@ -82,7 +79,7 @@ public final class SampleWithOwnerTest extends AbstractFileSystemTestCase { return new Object[][] { - { GROUP_CODE, "" }, + { GROUP_CODE, DATABASE_INSTANCE_CODE }, { "", DATABASE_INSTANCE_CODE }, }; } @@ -98,7 +95,7 @@ public final class SampleWithOwnerTest extends AbstractFileSystemTestCase if (groupCode.length() > 0) { assertEquals(GROUP_CODE, newSample.getGroupCode()); - assertEquals("", newSample.getDatabaseInstanceCode()); + assertEquals(DATABASE_INSTANCE_CODE, newSample.getDatabaseInstanceCode()); } else { assertEquals("", newSample.getGroupCode()); -- GitLab