-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: #1209 Adding test for HTTPEndpoint in testcontainers module
Signed-off-by: Laurent Broudoux <laurent.broudoux@gmail.com>
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 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
40 changes: 40 additions & 0 deletions
40
...rs-dapr/src/test/java/io/dapr/testcontainers/converter/HttpEndpointYamlConverterTest.java
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,40 @@ | ||
package io.dapr.testcontainers.converter; | ||
|
||
import io.dapr.testcontainers.DaprContainer; | ||
import io.dapr.testcontainers.HttpEndpoint; | ||
import org.junit.jupiter.api.Test; | ||
import org.yaml.snakeyaml.Yaml; | ||
|
||
import java.util.Set; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class HttpEndpointYamlConverterTest { | ||
private final Yaml MAPPER = YamlMapperFactory.create(); | ||
|
||
private final HttpEndpointYamlConverter converter = new HttpEndpointYamlConverter(MAPPER); | ||
|
||
@Test | ||
void testHttpEndpointToYaml() { | ||
DaprContainer dapr = new DaprContainer("daprio/daprd") | ||
.withAppName("dapr-app") | ||
.withAppPort(8081) | ||
.withHttpEndpoint(new HttpEndpoint("my-endpoint", "http://localhost:8080")) | ||
.withAppChannelAddress("host.testcontainers.internal"); | ||
|
||
Set<HttpEndpoint> endpoints = dapr.getHttpEndpoints(); | ||
assertEquals(1, endpoints.size()); | ||
|
||
HttpEndpoint endpoint = endpoints.iterator().next(); | ||
String endpointYaml = converter.convert(endpoint); | ||
String expectedEndpointYaml = | ||
"apiVersion: dapr.io/v1alpha1\n" | ||
+ "kind: HTTPEndpoint\n" | ||
+ "metadata:\n" | ||
+ " name: my-endpoint\n" | ||
+ "spec:\n" | ||
+ " baseUrl: http://localhost:8080\n"; | ||
|
||
assertEquals(expectedEndpointYaml, endpointYaml); | ||
} | ||
} |