Skip to content

Commit

Permalink
Completing OutlineRequiredOptionMissingException and corresponding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sangupta committed Sep 2, 2016
1 parent 5af7be7 commit 9f772d2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

package com.sangupta.outline.exceptions;

import com.sangupta.jerry.util.AssertUtils;

public class OutlineRequiredOptionMissingException extends OutlineException {

/**
Expand All @@ -31,6 +33,10 @@ public class OutlineRequiredOptionMissingException extends OutlineException {
public final String argument;

public OutlineRequiredOptionMissingException(String argument) {
if(AssertUtils.isEmpty(argument)) {
throw new IllegalArgumentException("Argument that is invalid cannot be null/empty");
}

this.argument = argument;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.sangupta.outline.exceptions;

import org.junit.Assert;
import org.junit.Test;

public class TestOutlineRequiredOptionMissingException {

@Test
public void test() {
OutlineRequiredOptionMissingException ex = new OutlineRequiredOptionMissingException("hello");

Assert.assertNotNull(ex);
Assert.assertNotNull(ex.argument);
Assert.assertEquals("hello", ex.argument);

try {
ex = new OutlineRequiredOptionMissingException(null);
Assert.assertTrue(false);
} catch(IllegalArgumentException e) {
Assert.assertTrue(true);
}

try {
ex = new OutlineRequiredOptionMissingException("");
Assert.assertTrue(false);
} catch(IllegalArgumentException e) {
Assert.assertTrue(true);
}
}

}

0 comments on commit 9f772d2

Please sign in to comment.