Ejemplo n.º 1
0
  @Test
  public void write_component() {
    // no data yet
    assertThat(underTest.hasComponentData(FileStructure.Domain.COMPONENT, 1)).isFalse();

    // write data
    BatchReport.Component.Builder component =
        BatchReport.Component.newBuilder()
            .setRef(1)
            .setLanguage("java")
            .setPath("src/Foo.java")
            .setType(Constants.ComponentType.FILE)
            .setIsTest(false)
            .addChildRef(5)
            .addChildRef(42);
    underTest.writeComponent(component.build());

    assertThat(underTest.hasComponentData(FileStructure.Domain.COMPONENT, 1)).isTrue();
    File file = underTest.getFileStructure().fileFor(FileStructure.Domain.COMPONENT, 1);
    assertThat(file).exists().isFile();
    BatchReport.Component read = Protobuf.read(file, BatchReport.Component.PARSER);
    assertThat(read.getRef()).isEqualTo(1);
    assertThat(read.getChildRefList()).containsOnly(5, 42);
    assertThat(read.hasName()).isFalse();
    assertThat(read.getIsTest()).isFalse();
  }
Ejemplo n.º 2
0
  @Test
  public void write_scm() {
    assertThat(underTest.hasComponentData(FileStructure.Domain.CHANGESETS, 1)).isFalse();

    BatchReport.Changesets scm =
        BatchReport.Changesets.newBuilder()
            .setComponentRef(1)
            .addChangesetIndexByLine(0)
            .addChangeset(
                BatchReport.Changesets.Changeset.newBuilder()
                    .setRevision("123-456-789")
                    .setAuthor("author")
                    .setDate(123_456_789L))
            .build();

    underTest.writeComponentChangesets(scm);

    assertThat(underTest.hasComponentData(FileStructure.Domain.CHANGESETS, 1)).isTrue();
    File file = underTest.getFileStructure().fileFor(FileStructure.Domain.CHANGESETS, 1);
    assertThat(file).exists().isFile();
    BatchReport.Changesets read = Protobuf.read(file, BatchReport.Changesets.PARSER);
    assertThat(read.getComponentRef()).isEqualTo(1);
    assertThat(read.getChangesetCount()).isEqualTo(1);
    assertThat(read.getChangesetList()).hasSize(1);
    assertThat(read.getChangeset(0).getDate()).isEqualTo(123_456_789L);
  }
Ejemplo n.º 3
0
  @Test
  public void write_metadata() {
    BatchReport.Metadata.Builder metadata =
        BatchReport.Metadata.newBuilder()
            .setAnalysisDate(15000000L)
            .setProjectKey("PROJECT_A")
            .setRootComponentRef(1);
    underTest.writeMetadata(metadata.build());

    BatchReport.Metadata read =
        Protobuf.read(underTest.getFileStructure().metadataFile(), BatchReport.Metadata.PARSER);
    assertThat(read.getAnalysisDate()).isEqualTo(15000000L);
    assertThat(read.getProjectKey()).isEqualTo("PROJECT_A");
    assertThat(read.getRootComponentRef()).isEqualTo(1);
  }