use of com.khartec.waltz.model.application.LifecyclePhase in project waltz by khartec.
the class AppGenerator method main.
public static void main(String[] args) throws IOException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
ApplicationService applicationDao = ctx.getBean(ApplicationService.class);
OrganisationalUnitService ouDao = ctx.getBean(OrganisationalUnitService.class);
List<String> animals = IOUtilities.readLines(AppGenerator.class.getClassLoader().getResourceAsStream("animals.txt"));
OrganisationalUnit[] organisationalUnits = ouDao.findAll().toArray(new OrganisationalUnit[0]);
List<AppRegistrationRequest> registrationRequests = new ArrayList<>();
for (int i = 0; i < 5000; i++) {
String animal = randomPick(animals.toArray(new String[0])) + " - " + i;
OrganisationalUnit organisationalUnit = randomPick(organisationalUnits);
LifecyclePhase phase = rnd.nextInt(10) > 7 ? randomPick(LifecyclePhase.values()) : LifecyclePhase.PRODUCTION;
Criticality businessCriticality = rnd.nextInt(10) > 7 ? randomPick(Criticality.values()) : Criticality.HIGH;
AppRegistrationRequest app = ImmutableAppRegistrationRequest.builder().name(animal).assetCode("wltz-0" + i).description("All about " + animal).applicationKind(randomPick(ApplicationKind.values())).lifecyclePhase(phase).overallRating(randomPick(RagRating.R, RagRating.A, RagRating.A, RagRating.G, RagRating.G)).organisationalUnitId(organisationalUnit.id().get()).businessCriticality(businessCriticality).build();
registrationRequests.add(app);
}
dsl.deleteFrom(AUTHORITATIVE_SOURCE).execute();
dsl.deleteFrom(APPLICATION).execute();
registrationRequests.forEach(a -> applicationDao.registerApp(a, "admin"));
}
Aggregations