Skip to content

Commit 19b4583

Browse files
committed
refact: rename
1 parent 6a6f588 commit 19b4583

File tree

2 files changed

+159
-51
lines changed

2 files changed

+159
-51
lines changed

pom.xml

+98-51
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<description>CAE EnvVars library</description>
88
<url>https://github.com/clean-arch-enablers-project/cae-utils-env-vars/blob/main/README.md</url>
99
<groupId>com.clean-arch-enablers</groupId>
10-
<artifactId>env-vars</artifactId>
11-
<version>0.0.1</version>
10+
<artifactId>cae-env-vars</artifactId>
11+
<version>1.0.0</version>
1212
<packaging>jar</packaging>
1313
<licenses>
1414
<license>
@@ -36,63 +36,110 @@
3636
<dependencies>
3737
<dependency>
3838
<groupId>com.clean-arch-enablers</groupId>
39-
<artifactId>trier</artifactId>
40-
<version>0.0.1</version>
39+
<artifactId>cae-trier</artifactId>
40+
<version>1.0.0</version>
41+
</dependency>
42+
<dependency>
43+
<groupId>ch.qos.logback</groupId>
44+
<artifactId>logback-classic</artifactId>
45+
<version>1.4.14</version>
46+
<scope>test</scope>
47+
</dependency>
48+
<dependency>
49+
<groupId>org.junit.jupiter</groupId>
50+
<artifactId>junit-jupiter-engine</artifactId>
51+
<version>5.9.0</version>
52+
<scope>test</scope>
53+
</dependency>
54+
<dependency>
55+
<groupId>org.mockito</groupId>
56+
<artifactId>mockito-core</artifactId>
57+
<version>4.8.0</version>
58+
<scope>test</scope>
59+
</dependency>
60+
<dependency>
61+
<groupId>org.mockito</groupId>
62+
<artifactId>mockito-junit-jupiter</artifactId>
63+
<version>4.8.0</version>
64+
<scope>test</scope>
4165
</dependency>
4266
</dependencies>
4367

68+
69+
<profiles>
70+
<profile>
71+
<id>deployment</id>
72+
<build>
73+
<plugins>
74+
<plugin>
75+
<groupId>org.sonatype.central</groupId>
76+
<artifactId>central-publishing-maven-plugin</artifactId>
77+
<version>0.4.0</version>
78+
<extensions>true</extensions>
79+
<configuration>
80+
<publishingServerId>central</publishingServerId>
81+
<tokenAuth>true</tokenAuth>
82+
</configuration>
83+
</plugin>
84+
<plugin>
85+
<groupId>org.apache.maven.plugins</groupId>
86+
<artifactId>maven-javadoc-plugin</artifactId>
87+
<version>3.3.0</version>
88+
<executions>
89+
<execution>
90+
<id>attach-javadocs</id>
91+
<goals>
92+
<goal>jar</goal>
93+
</goals>
94+
</execution>
95+
</executions>
96+
</plugin>
97+
<plugin>
98+
<groupId>org.apache.maven.plugins</groupId>
99+
<artifactId>maven-source-plugin</artifactId>
100+
<version>3.2.1</version>
101+
<executions>
102+
<execution>
103+
<id>attach-sources</id>
104+
<goals>
105+
<goal>jar</goal>
106+
</goals>
107+
</execution>
108+
</executions>
109+
</plugin>
110+
<plugin>
111+
<groupId>org.apache.maven.plugins</groupId>
112+
<artifactId>maven-gpg-plugin</artifactId>
113+
<version>1.6</version>
114+
<executions>
115+
<execution>
116+
<id>sign-artifacts</id>
117+
<phase>verify</phase>
118+
<goals>
119+
<goal>sign</goal>
120+
</goals>
121+
</execution>
122+
</executions>
123+
</plugin>
124+
</plugins>
125+
</build>
126+
</profile>
127+
</profiles>
128+
44129
<build>
45130
<plugins>
46131
<plugin>
47-
<groupId>org.sonatype.central</groupId>
48-
<artifactId>central-publishing-maven-plugin</artifactId>
49-
<version>0.4.0</version>
50-
<extensions>true</extensions>
132+
<artifactId>maven-surefire-plugin</artifactId>
133+
<version>2.22.2</version>
51134
<configuration>
52-
<publishingServerId>central</publishingServerId>
53-
<tokenAuth>true</tokenAuth>
135+
<environmentVariables>
136+
<EnvVarOne>some-normal-value</EnvVarOne>
137+
<EnvVarTwo>123</EnvVarTwo>
138+
<EnvVarThree>true</EnvVarThree>
139+
</environmentVariables>
54140
</configuration>
55141
</plugin>
56-
<plugin>
57-
<groupId>org.apache.maven.plugins</groupId>
58-
<artifactId>maven-javadoc-plugin</artifactId>
59-
<version>3.3.0</version>
60-
<executions>
61-
<execution>
62-
<id>attach-javadocs</id>
63-
<goals>
64-
<goal>jar</goal>
65-
</goals>
66-
</execution>
67-
</executions>
68-
</plugin>
69-
<plugin>
70-
<groupId>org.apache.maven.plugins</groupId>
71-
<artifactId>maven-source-plugin</artifactId>
72-
<version>3.2.1</version>
73-
<executions>
74-
<execution>
75-
<id>attach-sources</id>
76-
<goals>
77-
<goal>jar</goal>
78-
</goals>
79-
</execution>
80-
</executions>
81-
</plugin>
82-
<plugin>
83-
<groupId>org.apache.maven.plugins</groupId>
84-
<artifactId>maven-gpg-plugin</artifactId>
85-
<version>1.6</version>
86-
<executions>
87-
<execution>
88-
<id>sign-artifacts</id>
89-
<phase>deploy</phase>
90-
<goals>
91-
<goal>sign</goal>
92-
</goals>
93-
</execution>
94-
</executions>
95-
</plugin>
96142
</plugins>
97143
</build>
98-
</project>
144+
145+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package com.cae.env_vars;
2+
3+
import com.cae.env_vars.exceptions.MissingEnvVarException;
4+
import com.cae.env_vars.exceptions.UnexpectedException;
5+
import org.junit.jupiter.api.Assertions;
6+
import org.junit.jupiter.api.Test;
7+
import org.junit.jupiter.api.extension.ExtendWith;
8+
import org.mockito.junit.jupiter.MockitoExtension;
9+
10+
@ExtendWith(MockitoExtension.class)
11+
class EnvVarRetrieverTest {
12+
13+
@Test
14+
void shouldThrowMissingEnvVarExceptionWhenNoEnvVarIsFound(){
15+
Assertions.assertThrows(
16+
MissingEnvVarException.class,
17+
() -> EnvVarRetriever.getEnvVarByName("NON_EXISTENT_ENV_VAR_KEY", String.class)
18+
);
19+
}
20+
21+
@Test
22+
void shouldReturnTheEnvVarValueWhenExistent(){
23+
Assertions.assertDoesNotThrow(() -> {
24+
var value = (EnvVarRetriever.getEnvVarByName("EnvVarOne", String.class));
25+
Assertions.assertEquals("some-normal-value", value);
26+
});
27+
}
28+
29+
@Test
30+
void shouldReturnTheEnvVarValueAsString(){
31+
Assertions.assertDoesNotThrow(() -> {
32+
var value = (EnvVarRetriever.getEnvVarByNameAsString("EnvVarOne"));
33+
Assertions.assertEquals("some-normal-value", value);
34+
});
35+
}
36+
37+
@Test
38+
void shouldReturnTheEnvVarValueAsInteger(){
39+
Assertions.assertDoesNotThrow(() -> {
40+
var value = (EnvVarRetriever.getEnvVarByNameAsInteger("EnvVarTwo"));
41+
Assertions.assertEquals(123, value);
42+
});
43+
}
44+
45+
@Test
46+
void shouldReturnTheEnvVarValueAsBoolean(){
47+
Assertions.assertDoesNotThrow(() -> {
48+
var value = (EnvVarRetriever.getEnvVarByNameAsBoolean("EnvVarThree"));
49+
Assertions.assertEquals(true, value);
50+
});
51+
}
52+
53+
@Test
54+
void shouldThrowUnexpectedExceptionWhenSomeProblemHappensOtherThanMissingEnvVar(){
55+
Assertions.assertThrows(
56+
UnexpectedException.class,
57+
() -> EnvVarRetriever.getEnvVarByNameAsInteger("EnvVarThree")
58+
);
59+
}
60+
61+
}

0 commit comments

Comments
 (0)