Search in sources :

Example 1 with CodeBasePublication2

use of io.codekvast.javaagent.model.v2.CodeBasePublication2 in project codekvast by crispab.

the class PublicationV2DeserializationTest method should_deserialize_codebaseV2_file.

@Test
public void should_deserialize_codebaseV2_file() throws IOException, ClassNotFoundException {
    ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(getClass().getResourceAsStream(CODEBASE_RESOURCE)));
    CodeBasePublication2 publication = (CodeBasePublication2) ois.readObject();
    assertThat(publication, isA(CodeBasePublication2.class));
}
Also used : BufferedInputStream(java.io.BufferedInputStream) CodeBasePublication2(io.codekvast.javaagent.model.v2.CodeBasePublication2) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.jupiter.api.Test)

Example 2 with CodeBasePublication2

use of io.codekvast.javaagent.model.v2.CodeBasePublication2 in project codekvast by crispab.

the class IntakeIntegrationTest method should_import_codeBasePublication2.

@Test
public void should_import_codeBasePublication2() {
    // given
    assertThat(countRowsInTable("applications"), is(0));
    assertThat(countRowsInTable("environments"), is(0));
    assertThat(countRowsInTable("jvms"), is(0));
    assertThat(countRowsInTable("codebase_fingerprints"), is(0));
    assertThat(countRowsInTable("packages"), is(0));
    assertThat(countRowsInTable("types"), is(0));
    assertThat(countRowsInTable("methods"), is(0));
    assertThat(countRowsInTable("method_locations"), is(0));
    assertThat(countRowsInTable("invocations"), is(0));
    CodeBaseEntry2 entry1 = CodeBaseEntry2.sampleCodeBaseEntry();
    CodeBasePublication2 publication = CodeBasePublication2.builder().commonData(CommonPublicationData2.sampleCommonPublicationData()).entries(asList(entry1, entry1.toBuilder().signature(SYNTHETIC_SIGNATURE).build())).build();
    File file = writeToTempFile(publication);
    // when
    publicationImporter.importPublicationFile(file);
    // then
    assertThat(countRowsInTable("applications WHERE name = ?", publication.getCommonData().getAppName()), is(1));
    assertThat(countRowsInTable("environments WHERE name = ?", publication.getCommonData().getEnvironment()), is(1));
    assertThat(countRowsInTable("jvms WHERE uuid = ?", publication.getCommonData().getJvmUuid()), is(1));
    assertThat(countRowsInTable("methods WHERE signature = ?", entry1.getSignature()), is(1));
    assertThat(countRowsInTable("codebase_fingerprints WHERE codeBaseFingerprint = ?", publication.getCommonData().getCodeBaseFingerprint()), is(1));
    assertThat(countRowsInTable("method_locations"), // location is not supported in CodeBaseEntry2
    is(0));
    assertThat(countRowsInTable("packages WHERE name = ?", entry1.getMethodSignature().getPackageName()), is(1));
    assertThat(countRowsInTable("types WHERE name = ?", entry1.getMethodSignature().getDeclaringType()), is(1));
    assertThat(countRowsInTable("methods WHERE signature = ?", entry1.getSignature()), is(1));
    assertThat(countRowsInTable("methods WHERE signature = ?", SYNTHETIC_SIGNATURE), is(0));
    assertThat(countRowsInTable("invocations WHERE invokedAtMillis = 0"), is(1));
    assertThat(countRowsInTable("invocations WHERE status = ?", NOT_INVOKED.name()), is(1));
}
Also used : CodeBasePublication2(io.codekvast.javaagent.model.v2.CodeBasePublication2) CodeBaseEntry2(io.codekvast.javaagent.model.v2.CodeBaseEntry2) File(java.io.File) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 3 with CodeBasePublication2

use of io.codekvast.javaagent.model.v2.CodeBasePublication2 in project codekvast by crispab.

the class CodeBaseImporterImpl method importPublication.

@Override
@Transactional(rollbackFor = Exception.class)
public boolean importPublication(CodeBasePublication2 publication) {
    logger.info("Importing {}", publication);
    CommonPublicationData2 data = publication.getCommonData();
    long customerId = data.getCustomerId();
    long appId = importDAO.importApplication(data);
    long environmentId = importDAO.importEnvironment(data);
    long jvmId = importDAO.importJvm(data, appId, environmentId);
    importDAO.importMethods(data, customerId, appId, environmentId, jvmId, publication.getCommonData().getPublishedAtMillis(), publication.getEntries());
    return true;
}
Also used : CommonPublicationData2(io.codekvast.javaagent.model.v2.CommonPublicationData2) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with CodeBasePublication2

use of io.codekvast.javaagent.model.v2.CodeBasePublication2 in project codekvast by crispab.

the class CodeBasePublication2Test method should_transform_from_v1_format.

@SuppressWarnings("deprecation")
@Test
public void should_transform_from_v1_format() {
    CodeBasePublication pub1 = CodeBasePublication.builder().commonData(CommonPublicationData.sampleCommonPublicationData()).entries(Collections.singletonList(CodeBaseEntry.sampleCodeBaseEntry())).overriddenSignatures(Collections.singletonMap("key1", "value1")).strangeSignatures(Collections.singletonMap("key2", "value2")).build();
    CodeBasePublication2 pub2 = CodeBasePublication2.fromV1Format(pub1);
    assertThat(pub2.getCommonData(), is(CommonPublicationData2.sampleCommonPublicationData()));
    assertThat(pub2.getEntries(), hasItems(CodeBaseEntry2.sampleCodeBaseEntry()));
}
Also used : CodeBasePublication2(io.codekvast.javaagent.model.v2.CodeBasePublication2) CodeBasePublication(io.codekvast.javaagent.model.v1.CodeBasePublication) Test(org.junit.Test)

Aggregations

CodeBasePublication2 (io.codekvast.javaagent.model.v2.CodeBasePublication2)3 Test (org.junit.Test)2 CodeBasePublication (io.codekvast.javaagent.model.v1.CodeBasePublication)1 CodeBaseEntry2 (io.codekvast.javaagent.model.v2.CodeBaseEntry2)1 CommonPublicationData2 (io.codekvast.javaagent.model.v2.CommonPublicationData2)1 BufferedInputStream (java.io.BufferedInputStream)1 File (java.io.File)1 ObjectInputStream (java.io.ObjectInputStream)1 Test (org.junit.jupiter.api.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 Transactional (org.springframework.transaction.annotation.Transactional)1