Skip to content
Permalink
Browse files
notify: rename JsonUpdater to JsonNotifier
Reviewed-by: rwestberg
  • Loading branch information
edvbld committed Jun 10, 2020
1 parent 99c40da commit a0d76c5ea2f596cb2f28d20b07a77958d8a4c73d
@@ -28,6 +28,7 @@ module {
requires 'org.openjdk.skara.test'
opens 'org.openjdk.skara.bots.notify' to 'org.junit.platform.commons'
opens 'org.openjdk.skara.bots.notify.mailinglist' to 'org.junit.platform.commons'
opens 'org.openjdk.skara.bots.notify.json' to 'org.junit.platform.commons'
}
}

@@ -37,7 +37,7 @@
uses org.openjdk.skara.bots.notify.NotifierFactory;
provides org.openjdk.skara.bots.notify.NotifierFactory with
org.openjdk.skara.bots.notify.issue.IssueUpdaterFactory,
org.openjdk.skara.bots.notify.json.JsonUpdaterFactory,
org.openjdk.skara.bots.notify.json.JsonNotifierFactory,
org.openjdk.skara.bots.notify.mailinglist.MailingListNotifierFactory,
org.openjdk.skara.bots.notify.slack.SlackUpdaterFactory;
}
@@ -32,12 +32,12 @@
import java.time.format.DateTimeFormatter;
import java.util.*;

public class JsonUpdater implements RepositoryUpdateConsumer {
class JsonNotifier implements RepositoryUpdateConsumer {
private final Path path;
private final String version;
private final String defaultBuild;

public JsonUpdater(Path path, String version, String defaultBuild) {
JsonNotifier(Path path, String version, String defaultBuild) {
this.path = path;
this.version = version;
this.defaultBuild = defaultBuild;
@@ -78,7 +78,7 @@ private JSONObject issuesToChanges(HostedRepository repository, Repository local

@Override
public void handleCommits(HostedRepository repository, Repository localRepository, List<Commit> commits, Branch branch) throws NonRetriableException {
try (var writer = new JsonUpdateWriter(path, repository.name())) {
try (var writer = new JsonWriter(path, repository.name())) {
for (var commit : commits) {
var json = commitToChanges(repository, localRepository, commit, defaultBuild);
writer.write(json);
@@ -91,7 +91,7 @@ public void handleCommits(HostedRepository repository, Repository localRepositor
@Override
public void handleOpenJDKTagCommits(HostedRepository repository, Repository localRepository, List<Commit> commits, OpenJDKTag tag, Tag.Annotated annotation) throws NonRetriableException {
var build = String.format("b%02d", tag.buildNum());
try (var writer = new JsonUpdateWriter(path, repository.name())) {
try (var writer = new JsonWriter(path, repository.name())) {
var issues = new ArrayList<Issue>();
for (var commit : commits) {
var parsedMessage = CommitMessageParsers.v1.parse(commit);
@@ -104,14 +104,6 @@ public void handleOpenJDKTagCommits(HostedRepository repository, Repository loca
}
}

@Override
public void handleTagCommit(HostedRepository repository, Repository localRepository, Commit commit, Tag tag, Tag.Annotated annotation) {
}

@Override
public void handleNewBranch(HostedRepository repository, Repository localRepository, List<Commit> commits, Branch parent, Branch branch) {
}

@Override
public String name() {
return "json";
@@ -28,7 +28,7 @@

import java.nio.file.Path;

public class JsonUpdaterFactory implements NotifierFactory {
public class JsonNotifierFactory implements NotifierFactory {
@Override
public String name() {
return "json";
@@ -40,6 +40,6 @@ public Notifier create(BotConfiguration botConfiguration, JSONObject notifierCon
var build = notifierConfiguration.get("build").asString();
var version = notifierConfiguration.get("version").asString();

return new JsonUpdater(Path.of(folder), version, build);
return new JsonNotifier(Path.of(folder), version, build);
}
}
@@ -29,7 +29,7 @@
import java.nio.file.*;
import java.util.UUID;

public class JsonUpdateWriter implements AutoCloseable {
class JsonWriter implements AutoCloseable {

private int sequence = 0;
private final String baseName;
@@ -51,7 +51,7 @@ private void flush() {
current = JSON.array();
}

JsonUpdateWriter(Path path, String projectName) {
JsonWriter(Path path, String projectName) {
this.path = path;

var uuid = UUID.randomUUID();
@@ -20,10 +20,10 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.skara.bots.notify;
package org.openjdk.skara.bots.notify.json;

import org.junit.jupiter.api.*;
import org.openjdk.skara.bots.notify.json.JsonUpdater;
import org.openjdk.skara.bots.notify.*;
import org.openjdk.skara.json.*;
import org.openjdk.skara.test.*;

@@ -37,7 +37,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.openjdk.skara.bots.notify.UpdaterTests.*;

public class JsonUpdaterTests {
public class JsonNotifierTests {
private List<Path> findJsonFiles(Path folder, String partialName) throws IOException {
return Files.walk(folder)
.filter(path -> path.toString().endsWith(".json"))
@@ -46,7 +46,7 @@ private List<Path> findJsonFiles(Path folder, String partialName) throws IOExcep
}

@Test
void testJsonUpdaterBranch(TestInfo testInfo) throws IOException {
void testJsonNotifierBranch(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo);
var tempFolder = new TemporaryDirectory()) {
var repo = credentials.getHostedRepository();
@@ -62,7 +62,7 @@ void testJsonUpdaterBranch(TestInfo testInfo) throws IOException {
Files.createDirectory(jsonFolder);
var storageFolder = tempFolder.path().resolve("storage");

var updater = new JsonUpdater(jsonFolder, "12", "team");
var updater = new JsonNotifier(jsonFolder, "12", "team");
var notifyBot = NotifyBot.newBuilder()
.repository(repo)
.storagePath(storageFolder)
@@ -92,7 +92,7 @@ void testJsonUpdaterBranch(TestInfo testInfo) throws IOException {
}

@Test
void testJsonUpdaterTag(TestInfo testInfo) throws IOException {
void testJsonNotifierTag(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo);
var tempFolder = new TemporaryDirectory()) {
var repo = credentials.getHostedRepository();
@@ -110,7 +110,7 @@ void testJsonUpdaterTag(TestInfo testInfo) throws IOException {
Files.createDirectory(jsonFolder);
var storageFolder =tempFolder.path().resolve("storage");

var updater = new JsonUpdater(jsonFolder, "12", "team");
var updater = new JsonNotifier(jsonFolder, "12", "team");
var notifyBot = NotifyBot.newBuilder()
.repository(repo)
.storagePath(storageFolder)

0 comments on commit a0d76c5

Please sign in to comment.