Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2023
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. public class StatusOutput extends CommandTarget {
  2.  
  3. public StatusOutput(CallableMessage systemName, Iterable<Test> tests) {
  4. super(new Reply(() -> new MultiMessage(
  5. new LAPIMessage(
  6. CommonMessageDomains.Status.top,
  7. new Placeholder("system name", systemName)
  8. ),
  9. new ChatBook<>(
  10. tests,
  11. test -> new LAPIMessage(
  12. CommonMessageDomains.Status.testForm,
  13. new Placeholder("module name", test.name()),
  14. new Placeholder("status", identifier -> Value.of(test.makeTestFor(identifier)).useAs(result -> switch (result.status()) {
  15. case SUCCESS -> new LAPIMessage(CommonMessageDomains.Status.working);
  16. case SKIPPED -> new BadTestMessage(CommonMessageDomains.Status.down, result.description());
  17. case FAILURE -> new BadTestMessage(CommonMessageDomains.Status.testSkipped, result.description());
  18. }).call(identifier))
  19. )
  20. )
  21. )));
  22. }
  23.  
  24. private static class BadTestMessage extends CacheMessage {
  25.  
  26. public BadTestMessage(String mainMessageDomain, CallableMessage description) {
  27. super(new ClickableMessage(
  28. new HoveredMessage(
  29. new LAPIMessage(mainMessageDomain),
  30. new LAPIMessage(CommonMessageDomains.Status.pressToPrintDescription)
  31. ),
  32. click -> Communicator.of(click.clicker()).message(description)
  33. ));
  34. }
  35.  
  36. }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement