-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from clean-arch-enablers-project/refact/rename
refact: rename
- Loading branch information
Showing
2 changed files
with
159 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.cae.env_vars; | ||
|
||
import com.cae.env_vars.exceptions.MissingEnvVarException; | ||
import com.cae.env_vars.exceptions.UnexpectedException; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class EnvVarRetrieverTest { | ||
|
||
@Test | ||
void shouldThrowMissingEnvVarExceptionWhenNoEnvVarIsFound(){ | ||
Assertions.assertThrows( | ||
MissingEnvVarException.class, | ||
() -> EnvVarRetriever.getEnvVarByName("NON_EXISTENT_ENV_VAR_KEY", String.class) | ||
); | ||
} | ||
|
||
@Test | ||
void shouldReturnTheEnvVarValueWhenExistent(){ | ||
Assertions.assertDoesNotThrow(() -> { | ||
var value = (EnvVarRetriever.getEnvVarByName("EnvVarOne", String.class)); | ||
Assertions.assertEquals("some-normal-value", value); | ||
}); | ||
} | ||
|
||
@Test | ||
void shouldReturnTheEnvVarValueAsString(){ | ||
Assertions.assertDoesNotThrow(() -> { | ||
var value = (EnvVarRetriever.getEnvVarByNameAsString("EnvVarOne")); | ||
Assertions.assertEquals("some-normal-value", value); | ||
}); | ||
} | ||
|
||
@Test | ||
void shouldReturnTheEnvVarValueAsInteger(){ | ||
Assertions.assertDoesNotThrow(() -> { | ||
var value = (EnvVarRetriever.getEnvVarByNameAsInteger("EnvVarTwo")); | ||
Assertions.assertEquals(123, value); | ||
}); | ||
} | ||
|
||
@Test | ||
void shouldReturnTheEnvVarValueAsBoolean(){ | ||
Assertions.assertDoesNotThrow(() -> { | ||
var value = (EnvVarRetriever.getEnvVarByNameAsBoolean("EnvVarThree")); | ||
Assertions.assertEquals(true, value); | ||
}); | ||
} | ||
|
||
@Test | ||
void shouldThrowUnexpectedExceptionWhenSomeProblemHappensOtherThanMissingEnvVar(){ | ||
Assertions.assertThrows( | ||
UnexpectedException.class, | ||
() -> EnvVarRetriever.getEnvVarByNameAsInteger("EnvVarThree") | ||
); | ||
} | ||
|
||
} |