use of org.kie.kogito.codegen.api.GeneratedFile in project kogito-runtimes by kiegroup.
the class CustomDashboardGeneratedUtilsTest method loadCustomGrafanaDashboardsList.
@ParameterizedTest
@MethodSource("org.kie.kogito.codegen.api.utils.KogitoContextTestUtils#contextBuilders")
void loadCustomGrafanaDashboardsList(KogitoBuildContext.Builder contextBuilder) {
final KogitoBuildContext context = contextBuilder.withAppPaths(AppPaths.fromTestDir(new File(".").toPath())).build();
Collection<GeneratedFile> retrieved = CustomDashboardGeneratedUtils.loadCustomGrafanaDashboardsList(context);
assertNotNull(retrieved);
// 2 = valid *.json files inside src/test/META-INF/dashboards
assertEquals(2, retrieved.size());
}
use of org.kie.kogito.codegen.api.GeneratedFile in project kogito-runtimes by kiegroup.
the class CustomDashboardGeneratedUtilsTest method addToGeneratedFiles.
@ParameterizedTest
@MethodSource("org.kie.kogito.codegen.api.utils.KogitoContextTestUtils#contextBuilders")
void addToGeneratedFiles(KogitoBuildContext.Builder contextBuilder) {
final KogitoBuildContext context = contextBuilder.withAppPaths(AppPaths.fromTestDir(new File(".").toPath())).build();
Collection<CollectedResource> collectedResources = CollectedResourceProducer.fromPaths(context.getAppPaths().getPaths());
Map<String, List<Resource>> dashboardJsonsMap = CustomDashboardGeneratedUtils.getMappedJsons(collectedResources);
Collection<GeneratedFile> toPopulate = new ArrayList<>();
CustomDashboardGeneratedUtils.addToGeneratedFiles(dashboardJsonsMap.get(OPERATIONAL_DASHBOARD_PREFIX), toPopulate, operationalFunction, OPERATIONAL_DASHBOARD_PREFIX);
assertEquals(dashboardJsonsMap.get(OPERATIONAL_DASHBOARD_PREFIX).size(), toPopulate.size());
String sourcePath = dashboardJsonsMap.get(OPERATIONAL_DASHBOARD_PREFIX).get(0).getSourcePath();
String originalFileName = sourcePath.substring(sourcePath.lastIndexOf(File.separator) + 1);
validateGeneratedFile(toPopulate.iterator().next(), OPERATIONAL_DASHBOARD_PREFIX, originalFileName);
toPopulate = new ArrayList<>();
CustomDashboardGeneratedUtils.addToGeneratedFiles(dashboardJsonsMap.get(DOMAIN_DASHBOARD_PREFIX), toPopulate, domainFunction, DOMAIN_DASHBOARD_PREFIX);
assertEquals(dashboardJsonsMap.get(DOMAIN_DASHBOARD_PREFIX).size(), toPopulate.size());
sourcePath = dashboardJsonsMap.get(DOMAIN_DASHBOARD_PREFIX).get(0).getSourcePath();
originalFileName = sourcePath.substring(sourcePath.lastIndexOf(File.separator) + 1);
validateGeneratedFile(toPopulate.iterator().next(), DOMAIN_DASHBOARD_PREFIX, originalFileName);
}
use of org.kie.kogito.codegen.api.GeneratedFile in project kogito-runtimes by kiegroup.
the class GeneratedFileValidationTest method validateGeneratedFileTypes.
@Test
public void validateGeneratedFileTypes() {
List<GeneratedFile> generatedFiles = Arrays.asList(new GeneratedFile(GeneratedFileType.SOURCE, "myPath1", ""), new GeneratedFile(GeneratedFileType.INTERNAL_RESOURCE, "myPath2", ""), new GeneratedFile(GeneratedFileType.COMPILED_CLASS, "myPath3", ""), new GeneratedFile(GeneratedFileType.STATIC_HTTP_RESOURCE, "myPath4", ""));
GeneratedFileValidation.validateGeneratedFileTypes(generatedFiles, Arrays.asList(GeneratedFileType.Category.SOURCE, GeneratedFileType.Category.INTERNAL_RESOURCE, GeneratedFileType.Category.STATIC_HTTP_RESOURCE, GeneratedFileType.Category.COMPILED_CLASS));
Set<GeneratedFileType.Category> categories = Collections.singleton(GeneratedFileType.Category.SOURCE);
Assertions.assertThatThrownBy(() -> GeneratedFileValidation.validateGeneratedFileTypes(generatedFiles, categories)).isInstanceOf(IllegalStateException.class).hasMessageContaining("myPath2").hasMessageContaining("myPath3").hasMessageContaining("myPath4");
}
use of org.kie.kogito.codegen.api.GeneratedFile in project kogito-runtimes by kiegroup.
the class DashboardGeneratedFileUtils method operational.
public static List<GeneratedFile> operational(String operationalDashboard, String name) {
List<GeneratedFile> generatedFiles = new ArrayList<>();
generatedFiles.add(new GeneratedFile(DASHBOARD_TYPE, STATIC_RESOURCE_PATH + OPERATIONAL_DASHBOARD_PREFIX + name.replaceAll(DASHBOARD_NAME_REGEX, ""), operationalDashboard));
return generatedFiles;
}
use of org.kie.kogito.codegen.api.GeneratedFile in project kogito-runtimes by kiegroup.
the class DashboardGeneratedFileUtils method domain.
public static List<GeneratedFile> domain(String domainDashboard, String name) {
List<GeneratedFile> generatedFiles = new ArrayList<>();
generatedFiles.add(new GeneratedFile(DASHBOARD_TYPE, STATIC_RESOURCE_PATH + DOMAIN_DASHBOARD_PREFIX + name.replaceAll(DASHBOARD_NAME_REGEX, ""), domainDashboard));
return generatedFiles;
}
Aggregations