< prev index next >

bots/notify/src/test/java/org/openjdk/skara/bots/notify/UpdaterTests.java

Print this page

703             assertEquals("value2", email.headerValue("extra2"));
704 
705             TestBotRunner.runPeriodicItems(notifyBot);
706             assertThrows(RuntimeException.class, () -> listServer.processIncoming(Duration.ofMillis(1)));
707 
708             localRepo.push(editHash, repo.url(), "newbranch2");
709             TestBotRunner.runPeriodicItems(notifyBot);
710             listServer.processIncoming();
711 
712             var newConversation = mailmanList.conversations(Duration.ofDays(1)).stream()
713                                              .filter(c -> !c.equals(conversations.get(0)))
714                                              .findFirst().orElseThrow();
715             email = newConversation.first();
716             assertEquals(listAddress, email.sender());
717             assertEquals(sender, email.author());
718             assertEquals(email.recipients(), List.of(listAddress));
719             assertEquals("git: test: created branch newbranch2 based on the branch newbranch1 containing 0 unique commits", email.subject());
720             assertEquals("The new branch newbranch2 is currently identical to the newbranch1 branch.", email.body());
721         }
722     }






































723 }

703             assertEquals("value2", email.headerValue("extra2"));
704 
705             TestBotRunner.runPeriodicItems(notifyBot);
706             assertThrows(RuntimeException.class, () -> listServer.processIncoming(Duration.ofMillis(1)));
707 
708             localRepo.push(editHash, repo.url(), "newbranch2");
709             TestBotRunner.runPeriodicItems(notifyBot);
710             listServer.processIncoming();
711 
712             var newConversation = mailmanList.conversations(Duration.ofDays(1)).stream()
713                                              .filter(c -> !c.equals(conversations.get(0)))
714                                              .findFirst().orElseThrow();
715             email = newConversation.first();
716             assertEquals(listAddress, email.sender());
717             assertEquals(sender, email.author());
718             assertEquals(email.recipients(), List.of(listAddress));
719             assertEquals("git: test: created branch newbranch2 based on the branch newbranch1 containing 0 unique commits", email.subject());
720             assertEquals("The new branch newbranch2 is currently identical to the newbranch1 branch.", email.body());
721         }
722     }
723 
724     @Test
725     void testIssue(TestInfo testInfo) throws IOException {
726         try (var credentials = new HostCredentials(testInfo);
727              var tempFolder = new TemporaryDirectory()) {
728             var repo = credentials.getHostedRepository();
729             var repoFolder = tempFolder.path().resolve("repo");
730             var localRepo = CheckableRepository.init(repoFolder, repo.repositoryType());
731             credentials.commitLock(localRepo);
732             localRepo.pushAll(repo.url());
733 
734             var tagStorage = createTagStorage(repo);
735             var branchStorage = createBranchStorage(repo);
736             var storageFolder = tempFolder.path().resolve("storage");
737 
738             var issueProject = credentials.getIssueProject();
739             var updater = new IssueUpdater(issueProject);
740             var notifyBot = new JNotifyBot(repo, storageFolder, Pattern.compile("master"), tagStorage, branchStorage, List.of(updater));
741 
742             // Initialize history
743             TestBotRunner.runPeriodicItems(notifyBot);
744 
745             // Create an issue and commit a fix
746             var issue = issueProject.createIssue("This is an issue", List.of("Indeed"));
747             var editHash = CheckableRepository.appendAndCommit(localRepo, "Another line", issue.id() + ": Fix that issue");
748             localRepo.push(editHash, repo.url(), "master");
749             TestBotRunner.runPeriodicItems(notifyBot);
750 
751             // The changeset should be reflected in a comment
752             var comments = issue.comments();
753             assertEquals(1, comments.size());
754             var comment = comments.get(0);
755             assertTrue(comment.body().contains(editHash.abbreviate()));
756 
757             // There should be no open issues
758             assertEquals(0, issueProject.issues().size());
759         }
760     }
761 }
< prev index next >