|
16 | 16 |
|
17 | 17 | package io.opentelemetry.contrib.generator.telemetry;
|
18 | 18 |
|
| 19 | +import com.fasterxml.jackson.databind.ObjectMapper; |
| 20 | +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; |
| 21 | +import io.opentelemetry.contrib.generator.telemetry.cli.dto.TargetEnvironmentDetails; |
19 | 22 | import io.opentelemetry.contrib.generator.telemetry.dto.GeneratorInput;
|
20 | 23 | import org.testng.annotations.Test;
|
21 | 24 |
|
| 25 | +import java.io.File; |
| 26 | +import java.io.IOException; |
22 | 27 | import java.nio.file.Paths;
|
23 | 28 |
|
24 | 29 | public class ValidateExampleDefinitionsTest {
|
25 |
| - |
26 |
| - private final String DEFINITION_PATH = Paths.get(System.getProperty("user.dir"), "example-definitions", "qa").toString(); |
| 30 | + |
| 31 | + private final String DEFINITION_BASE_PATH = Paths.get(System.getProperty("user.dir"), "example-definitions").toString(); |
| 32 | + private final String DEFINITION_PATH = Paths.get(DEFINITION_BASE_PATH, "qa").toString(); |
27 | 33 |
|
28 | 34 | @Test
|
29 |
| - public void validateEntityAndMetricDefinitions() { |
| 35 | + public void validateQAEntityAndMetricDefinitions() { |
30 | 36 | String entityDefinitions = Paths.get(DEFINITION_PATH, "entity-definition.yaml").toString();
|
31 | 37 | String metricDefinitions = Paths.get(DEFINITION_PATH, "metric-definition.yaml").toString();
|
32 | 38 | GeneratorInput generatorInput = new GeneratorInput.YAMLFilesBuilder(entityDefinitions)
|
33 | 39 | .withMetricDefinitionYAML(metricDefinitions).build();
|
34 |
| - generatorInput.validate("ValidateExampleDefinitionsTest_EntityMetricDefinitions"); |
| 40 | + generatorInput.validate("ValidateQAExampleDefinitionsTest_EntityMetricDefinitions"); |
35 | 41 | }
|
36 | 42 |
|
37 | 43 | @Test
|
38 |
| - public void validateLogDefinitions() { |
| 44 | + public void validateQALogDefinitions() { |
39 | 45 | String entityDefinitions = Paths.get(DEFINITION_PATH, "entity-definition.yaml").toString();
|
40 | 46 | String logDefinitions = Paths.get(DEFINITION_PATH, "log-definition.yaml").toString();
|
41 | 47 | GeneratorInput generatorInput = new GeneratorInput.YAMLFilesBuilder(entityDefinitions)
|
42 | 48 | .withLogDefinitionYAML(logDefinitions).build();
|
43 |
| - generatorInput.validate("ValidateExampleDefinitionsTest_LogDefinitions"); |
| 49 | + generatorInput.validate("ValidateQAExampleDefinitionsTest_LogDefinitions"); |
44 | 50 | }
|
45 | 51 |
|
46 | 52 | @Test
|
47 |
| - public void validateTraceDefinitions() { |
| 53 | + public void validateQATraceDefinitions() { |
48 | 54 | String entityDefinitions = Paths.get(DEFINITION_PATH, "entity-definition.yaml").toString();
|
49 | 55 | String traceDefinitions = Paths.get(DEFINITION_PATH, "trace-definition.yaml").toString();
|
50 | 56 | GeneratorInput generatorInput = new GeneratorInput.YAMLFilesBuilder(entityDefinitions)
|
51 | 57 | .withTraceDefinitionYAML(traceDefinitions).build();
|
52 |
| - generatorInput.validate("ValidateExampleDefinitionsTest_TraceDefinitions"); |
| 58 | + generatorInput.validate("ValidateQAExampleDefinitionsTest_TraceDefinitions"); |
| 59 | + } |
| 60 | + |
| 61 | + @Test |
| 62 | + public void validateDemoEntityAndTraceDefinitions() { |
| 63 | + String entityDefinitions = Paths.get(DEFINITION_BASE_PATH, "demo", "entity-definition.yaml").toString(); |
| 64 | + String tracesDefinitions = Paths.get(DEFINITION_BASE_PATH, "demo", "trace-definition.yaml").toString(); |
| 65 | + GeneratorInput generatorInput = new GeneratorInput.YAMLFilesBuilder(entityDefinitions) |
| 66 | + .withTraceDefinitionYAML(tracesDefinitions).build(); |
| 67 | + generatorInput.validate("ValidateDemoExampleDefinitionsTest_EntityTraceDefinitions"); |
| 68 | + } |
| 69 | + |
| 70 | + @Test |
| 71 | + public void validateSimpleEntityAndTraceDefinitions() { |
| 72 | + String entityDefinitions = Paths.get(DEFINITION_BASE_PATH, "simple", "entity-definition.yaml").toString(); |
| 73 | + String tracesDefinitions = Paths.get(DEFINITION_BASE_PATH, "simple", "trace-definition.yaml").toString(); |
| 74 | + GeneratorInput generatorInput = new GeneratorInput.YAMLFilesBuilder(entityDefinitions) |
| 75 | + .withTraceDefinitionYAML(tracesDefinitions).build(); |
| 76 | + generatorInput.validate("ValidateSimpleExampleDefinitionsTest_EntityTraceDefinitions"); |
| 77 | + } |
| 78 | + |
| 79 | + @Test |
| 80 | + public void validateCLITargetYAMLs() throws IOException { |
| 81 | + File cliRestTargetYAML = Paths.get(DEFINITION_BASE_PATH, "cli-target-rest.yaml").toFile(); |
| 82 | + File cligRPCTargetYAML = Paths.get(DEFINITION_BASE_PATH, "cli-target-grpc.yaml").toFile(); |
| 83 | + ObjectMapper yamlMapper = new ObjectMapper(new YAMLFactory()); |
| 84 | + yamlMapper.readValue(cliRestTargetYAML, TargetEnvironmentDetails.class); |
| 85 | + yamlMapper.readValue(cligRPCTargetYAML, TargetEnvironmentDetails.class); |
53 | 86 | }
|
54 | 87 | }
|
0 commit comments