Search in sources :

Example 21 with SerializerEngine

use of fr.inria.spirals.repairnator.serializer.engines.SerializerEngine in project repairnator by Spirals-Team.

the class TestProjectInspector4Bears method testPassingPassingProject.

@Test
public void testPassingPassingProject() throws IOException, GitAPIException {
    int buildIdPassing = 201938881;
    int buildIdPreviousPassing = 201938325;
    Path tmpDirPath = Files.createTempDirectory("test_bears2");
    File tmpDir = tmpDirPath.toFile();
    tmpDir.deleteOnExit();
    Build passingBuild = BuildHelper.getBuildFromId(buildIdPassing, null);
    Build previousPassingBuild = BuildHelper.getBuildFromId(buildIdPreviousPassing, null);
    BuildToBeInspected buildToBeInspected = new BuildToBeInspected(previousPassingBuild, passingBuild, ScannedBuildStatus.PASSING_AND_PASSING_WITH_TEST_CHANGES, "test");
    List<AbstractDataSerializer> serializers = new ArrayList<>();
    List<AbstractNotifier> notifiers = new ArrayList<>();
    List<SerializerEngine> serializerEngines = new ArrayList<>();
    SerializerEngine serializerEngine = mock(SerializerEngine.class);
    serializerEngines.add(serializerEngine);
    List<NotifierEngine> notifierEngines = new ArrayList<>();
    NotifierEngine notifierEngine = mock(NotifierEngine.class);
    notifierEngines.add(notifierEngine);
    serializers.add(new InspectorSerializer4Bears(serializerEngines));
    notifiers.add(new FixerBuildNotifier(notifierEngines));
    RepairnatorConfig config = RepairnatorConfig.getInstance();
    config.setLauncherMode(LauncherMode.BEARS);
    ProjectInspector4Bears inspector = new ProjectInspector4Bears(buildToBeInspected, tmpDir.getAbsolutePath(), serializers, notifiers);
    inspector.run();
    JobStatus jobStatus = inspector.getJobStatus();
    assertThat(jobStatus.getPipelineState(), is(PipelineState.FIXERBUILDCASE2));
    assertThat(jobStatus.getPushState(), is(PushState.PATCH_COMMITTED));
    assertThat(inspector.isFixerBuildCase2(), is(true));
    assertThat(jobStatus.getFailureLocations().size(), is(1));
    assertThat(jobStatus.getMetrics().getFailureNames().size(), is(1));
    verify(notifierEngine, times(1)).notify(anyString(), anyString());
    verify(serializerEngine, times(1)).serialize(anyListOf(SerializedData.class), eq(SerializerType.INSPECTOR4BEARS));
    Git gitDir = Git.open(new File(inspector.getRepoToPushLocalPath()));
    Iterable<RevCommit> logs = gitDir.log().call();
    Iterator<RevCommit> iterator = logs.iterator();
    assertThat(iterator.hasNext(), is(true));
    RevCommit commit = iterator.next();
    assertThat(commit.getShortMessage(), containsString("End of the repairnator process"));
    commit = iterator.next();
    assertThat(commit.getShortMessage(), containsString("Human patch"));
    commit = iterator.next();
    assertThat(commit.getShortMessage(), containsString("Automatic repair"));
    commit = iterator.next();
    assertThat(commit.getShortMessage(), containsString("Bug commit"));
    assertThat(iterator.hasNext(), is(false));
}
Also used : Path(java.nio.file.Path) AbstractNotifier(fr.inria.spirals.repairnator.notifier.AbstractNotifier) RepairnatorConfig(fr.inria.spirals.repairnator.config.RepairnatorConfig) InspectorSerializer4Bears(fr.inria.spirals.repairnator.serializer.InspectorSerializer4Bears) ArrayList(java.util.ArrayList) FixerBuildNotifier(fr.inria.spirals.repairnator.notifier.FixerBuildNotifier) SerializerEngine(fr.inria.spirals.repairnator.serializer.engines.SerializerEngine) SerializedData(fr.inria.spirals.repairnator.serializer.engines.SerializedData) AbstractDataSerializer(fr.inria.spirals.repairnator.serializer.AbstractDataSerializer) BuildToBeInspected(fr.inria.spirals.repairnator.BuildToBeInspected) Git(org.eclipse.jgit.api.Git) Build(fr.inria.jtravis.entities.Build) NotifierEngine(fr.inria.spirals.repairnator.notifier.engines.NotifierEngine) File(java.io.File) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Example 22 with SerializerEngine

use of fr.inria.spirals.repairnator.serializer.engines.SerializerEngine in project repairnator by Spirals-Team.

the class BlacklistedSerializer method serialize.

public void serialize(Repository repo, Reason reason, String comment) {
    SerializedData data = new SerializedData(this.serializeAsList(repo, reason, comment), this.serializeAsJson(repo, reason, comment));
    List<SerializedData> allData = new ArrayList<>();
    allData.add(data);
    for (SerializerEngine engine : this.getEngines()) {
        engine.serialize(allData, this.getType());
    }
}
Also used : ArrayList(java.util.ArrayList) SerializedData(fr.inria.spirals.repairnator.serializer.engines.SerializedData) SerializerEngine(fr.inria.spirals.repairnator.serializer.engines.SerializerEngine)

Example 23 with SerializerEngine

use of fr.inria.spirals.repairnator.serializer.engines.SerializerEngine in project repairnator by Spirals-Team.

the class Launcher method initSerializerEngines.

private void initSerializerEngines() {
    this.engines = new ArrayList<>();
    SerializerEngine spreadsheetSerializerEngine = LauncherUtils.initSpreadsheetSerializerEngineWithFileSecret(LOGGER);
    if (spreadsheetSerializerEngine != null) {
        this.engines.add(spreadsheetSerializerEngine);
    }
    List<SerializerEngine> fileSerializerEngines = LauncherUtils.initFileSerializerEngines(LOGGER);
    this.engines.addAll(fileSerializerEngines);
    SerializerEngine mongoDBSerializerEngine = LauncherUtils.initMongoDBSerializerEngine(LOGGER);
    if (mongoDBSerializerEngine != null) {
        this.engines.add(mongoDBSerializerEngine);
    }
}
Also used : SerializerEngine(fr.inria.spirals.repairnator.serializer.engines.SerializerEngine)

Example 24 with SerializerEngine

use of fr.inria.spirals.repairnator.serializer.engines.SerializerEngine in project repairnator by Spirals-Team.

the class AstorSerializer method serializeData.

@Override
public void serializeData(ProjectInspector inspector) {
    JsonElement result = inspector.getJobStatus().getAstorResults();
    if (result != null) {
        List<Object> dataAsList = new ArrayList<>();
        dataAsList.add(Utils.getHostname());
        dataAsList.add(inspector.getBuildToBeInspected().getRunId());
        dataAsList.add(Utils.formatCompleteDate(new Date()));
        dataAsList.add(Utils.formatOnlyDay(new Date()));
        dataAsList.add(inspector.getRepoSlug());
        dataAsList.add(inspector.getBuggyBuild().getId());
        dataAsList.add(result.toString());
        JsonObject dataAsJson = new JsonObject();
        dataAsJson.addProperty("hostname", Utils.getHostname());
        dataAsJson.addProperty("runId", inspector.getBuildToBeInspected().getRunId());
        dataAsJson.addProperty("buildId", inspector.getBuggyBuild().getId());
        dataAsJson.addProperty("repositoryName", inspector.getRepoSlug());
        this.addDate(dataAsJson, "computedDate", new Date());
        dataAsJson.addProperty("computedDateStr", Utils.formatCompleteDate(new Date()));
        dataAsJson.addProperty("computedDay", Utils.formatOnlyDay(new Date()));
        dataAsJson.add("result", result);
        List<SerializedData> serializedData = new ArrayList<>();
        serializedData.add(new SerializedData(dataAsList, dataAsJson));
        for (SerializerEngine engine : this.getEngines()) {
            engine.serialize(serializedData, this.getType());
        }
    }
}
Also used : JsonElement(com.google.gson.JsonElement) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) JsonObject(com.google.gson.JsonObject) SerializedData(fr.inria.spirals.repairnator.serializer.engines.SerializedData) SerializerEngine(fr.inria.spirals.repairnator.serializer.engines.SerializerEngine) Date(java.util.Date)

Example 25 with SerializerEngine

use of fr.inria.spirals.repairnator.serializer.engines.SerializerEngine in project repairnator by Spirals-Team.

the class InspectorSerializer method serializeData.

@Override
public void serializeData(ProjectInspector inspector) {
    SerializedData data = new SerializedData(this.serializeAsList(inspector), this.serializeAsJson(inspector));
    List<SerializedData> allData = new ArrayList<>();
    allData.add(data);
    for (SerializerEngine engine : this.getEngines()) {
        engine.serialize(allData, this.getType());
    }
}
Also used : ArrayList(java.util.ArrayList) SerializedData(fr.inria.spirals.repairnator.serializer.engines.SerializedData) SerializerEngine(fr.inria.spirals.repairnator.serializer.engines.SerializerEngine) MongoDBSerializerEngine(fr.inria.spirals.repairnator.serializer.engines.json.MongoDBSerializerEngine)

Aggregations

SerializerEngine (fr.inria.spirals.repairnator.serializer.engines.SerializerEngine)28 ArrayList (java.util.ArrayList)24 SerializedData (fr.inria.spirals.repairnator.serializer.engines.SerializedData)23 BuildToBeInspected (fr.inria.spirals.repairnator.BuildToBeInspected)8 RepairnatorConfig (fr.inria.spirals.repairnator.config.RepairnatorConfig)8 Build (fr.inria.jtravis.entities.Build)7 AbstractNotifier (fr.inria.spirals.repairnator.notifier.AbstractNotifier)7 AbstractDataSerializer (fr.inria.spirals.repairnator.serializer.AbstractDataSerializer)7 MongoDBSerializerEngine (fr.inria.spirals.repairnator.serializer.engines.json.MongoDBSerializerEngine)7 File (java.io.File)7 Path (java.nio.file.Path)7 Test (org.junit.Test)7 NotifierEngine (fr.inria.spirals.repairnator.notifier.engines.NotifierEngine)5 InspectorSerializer (fr.inria.spirals.repairnator.serializer.InspectorSerializer)5 NopolSerializer (fr.inria.spirals.repairnator.serializer.NopolSerializer)5 Git (org.eclipse.jgit.api.Git)5 RevCommit (org.eclipse.jgit.revwalk.RevCommit)5 JsonObject (com.google.gson.JsonObject)4 Date (java.util.Date)4 PatchNotifier (fr.inria.spirals.repairnator.notifier.PatchNotifier)3