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));
}
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));
}
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;
}
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()));
}
Aggregations