Skip to content
Snippets Groups Projects
Commit b9b9cf6e authored by ribeaudc's avatar ribeaudc
Browse files

[LMS-531] fix: - Database instance code is never empty in 'SampleWithOwner'.

SVN: 7831
parent 2af8f5f3
No related branches found
No related tags found
No related merge requests found
...@@ -64,23 +64,16 @@ public final class SampleWithOwner extends Sample ...@@ -64,23 +64,16 @@ public final class SampleWithOwner extends Sample
super(code, typeCode, typeDescription); super(code, typeCode, typeDescription);
assert groupCode != null : "Undefined group code."; assert groupCode != null : "Undefined group code.";
assert databaseInstanceCode != null : "Undefined database instance code."; assert databaseInstanceCode != null : "Undefined database instance code.";
assertOneNonEmpty(groupCode, databaseInstanceCode); assertNonEmptyDatabaseInstanceCode(databaseInstanceCode);
this.groupCode = groupCode; this.groupCode = groupCode;
this.databaseInstanceCode = databaseInstanceCode; this.databaseInstanceCode = databaseInstanceCode;
} }
private final static void assertOneNonEmpty(final String groupCode, private final static void assertNonEmptyDatabaseInstanceCode(final String databaseInstanceCode)
final String databaseInstanceCode)
{ {
if (groupCode.length() == 0 && databaseInstanceCode.length() == 0) if (databaseInstanceCode.length() == 0)
{
throw new DataStructureException(
"Both, group code and database instance code, are empty.");
}
if (groupCode.length() > 0 && databaseInstanceCode.length() > 0)
{ {
throw new DataStructureException("At most one, the group code OR the database " throw new DataStructureException("Empty database instance code.");
+ "instance code, must be non empty.");
} }
} }
......
...@@ -66,15 +66,12 @@ public final class SampleWithOwnerTest extends AbstractFileSystemTestCase ...@@ -66,15 +66,12 @@ public final class SampleWithOwnerTest extends AbstractFileSystemTestCase
} }
try try
{ {
new SampleWithOwner(CODE, TYPE_CODE, TYPE_DESCRIPTION, GROUP_CODE, new SampleWithOwner(CODE, TYPE_CODE, TYPE_DESCRIPTION, GROUP_CODE, "");
DATABASE_INSTANCE_CODE);
fail(); fail();
} catch (final DataStructureException e) } catch (final DataStructureException e)
{ {
// Nothing to do here. // Nothing to do here.
} }
assertEquals(false, fail);
new SampleWithOwner(CODE, TYPE_CODE, TYPE_DESCRIPTION, GROUP_CODE, "");
} }
@DataProvider @DataProvider
...@@ -82,7 +79,7 @@ public final class SampleWithOwnerTest extends AbstractFileSystemTestCase ...@@ -82,7 +79,7 @@ public final class SampleWithOwnerTest extends AbstractFileSystemTestCase
{ {
return new Object[][] return new Object[][]
{ {
{ GROUP_CODE, "" }, { GROUP_CODE, DATABASE_INSTANCE_CODE },
{ "", DATABASE_INSTANCE_CODE }, }; { "", DATABASE_INSTANCE_CODE }, };
} }
...@@ -98,7 +95,7 @@ public final class SampleWithOwnerTest extends AbstractFileSystemTestCase ...@@ -98,7 +95,7 @@ public final class SampleWithOwnerTest extends AbstractFileSystemTestCase
if (groupCode.length() > 0) if (groupCode.length() > 0)
{ {
assertEquals(GROUP_CODE, newSample.getGroupCode()); assertEquals(GROUP_CODE, newSample.getGroupCode());
assertEquals("", newSample.getDatabaseInstanceCode()); assertEquals(DATABASE_INSTANCE_CODE, newSample.getDatabaseInstanceCode());
} else } else
{ {
assertEquals("", newSample.getGroupCode()); assertEquals("", newSample.getGroupCode());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment