File tree Expand file tree Collapse file tree
main/java/com/bettercloud/vault
test/java/com/bettercloud/vault Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -84,10 +84,11 @@ public VaultConfig environmentLoader(final EnvironmentLoader environmentLoader)
8484 * @return This object, with the namespace populated, ready for additional builder-pattern method calls or else
8585 * finalization with the build() method
8686 */
87- public VaultConfig nameSpace (final String nameSpace ) {
88- assert !nameSpace .isEmpty ();
89- this .nameSpace = nameSpace ;
90- return this ;
87+ public VaultConfig nameSpace (final String nameSpace ) throws VaultException {
88+ if (nameSpace != null && !nameSpace .isEmpty ()) {
89+ this .nameSpace = nameSpace ;
90+ return this ;
91+ } else throw new VaultException ("A namespace cannot be empty." );
9192 }
9293
9394 /**
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ public void testGlobalEngineVersionVaultConstructor() {
2929 }
3030
3131 @ Test
32- public void testNameSpaceProvidedVaultConstructor () {
32+ public void testNameSpaceProvidedVaultConstructor () throws VaultException {
3333 VaultConfig vaultConfig = new VaultConfig ().nameSpace ("testNameSpace" );
3434 Vault vault = new Vault (vaultConfig , 1 );
3535 Assert .assertNotNull (vault );
@@ -39,19 +39,11 @@ public void testNameSpaceProvidedVaultConstructor() {
3939 public void testNameSpaceProvidedVaultConstructorCannotBeEmpty () {
4040 try {
4141 VaultConfig vaultConfig = new VaultConfig ().nameSpace ("" );
42- } catch (AssertionError e ) {
43- Assert .assertEquals (e .getClass (), AssertionError . class );
42+ } catch (VaultException e ) {
43+ Assert .assertEquals (e .getMessage (), "A namespace cannot be empty." );
4444 }
4545 }
4646
47-
48- @ Test
49- public void testNameSpaceNotProvidedVaultConstructor () {
50- VaultConfig vaultConfig = new VaultConfig ().nameSpace (null );
51- Vault vault = new Vault (vaultConfig , 1 );
52- Assert .assertNotNull (vault );
53- }
54-
5547 @ Test (expected = IllegalArgumentException .class )
5648 public void testInvalidGlobalEngineVersionVaultConstructor () {
5749 VaultConfig vaultConfig = new VaultConfig ();
You can’t perform that action at this time.
0 commit comments