use of no.mnemonic.act.platform.dao.api.record.ObjectRecord in project act-platform by mnemonic-no.
the class ObjectFactDaoFacadeTest method testGetObjectByTypeValue.
@Test
public void testGetObjectByTypeValue() {
String type = "type";
String value = "value";
ObjectRecord record = new ObjectRecord();
when(objectResolver.getObject(type, value)).thenReturn(record);
assertSame(record, dao.getObject(type, value));
verify(objectResolver).getObject(type, value);
}
use of no.mnemonic.act.platform.dao.api.record.ObjectRecord in project act-platform by mnemonic-no.
the class ObjectFactDaoFacadeTest method testStoreObjectSavesEntity.
@Test
public void testStoreObjectSavesEntity() {
ObjectRecord record = new ObjectRecord().setId(UUID.randomUUID());
ObjectEntity entity = new ObjectEntity().setId(record.getId());
when(objectRecordConverter.toEntity(record)).thenReturn(entity);
assertSame(record, dao.storeObject(record));
verify(objectRecordConverter).toEntity(argThat(r -> r.getId() == record.getId()));
verify(objectManager).saveObject(entity);
}
use of no.mnemonic.act.platform.dao.api.record.ObjectRecord in project act-platform by mnemonic-no.
the class ActGraphIT method testFilterByTime.
@Test
public void testFilterByTime() {
ObjectRecord someIp = createObject(ipType.getId(), "2.2.2.2");
ObjectRecord someDomain = createObject(domainType.getId(), "test.org");
objectFactDao.storeObject(someIp);
objectFactDao.storeObject(someDomain);
Long t0 = 98000000L;
Long beforeT0 = t0 - 10;
Long afterT0 = t0 + 10;
FactRecord someFact = new FactRecord().setId(UUID.randomUUID()).setTypeID(resolveType.getId()).setAccessMode(FactRecord.AccessMode.Public).setValue("to").setTimestamp(t0).setLastSeenTimestamp(t0).setSourceObject(someIp).setDestinationObject(someDomain);
objectFactDao.storeFact(someFact);
// No time filter
assertEquals(1, IteratorUtils.count(createGraph(TraverseParams.builder().build()).V(someIp.getId()).outE("resolve")));
// Just before
assertEquals(0, IteratorUtils.count(createGraph(TraverseParams.builder().setBeforeTimestamp(beforeT0).build()).V(someIp.getId()).outE("resolve")));
// Just after
assertEquals(0, IteratorUtils.count(createGraph(TraverseParams.builder().setAfterTimestamp(afterT0).build()).V(someIp.getId()).outE("resolve")));
// In between
assertEquals(1, IteratorUtils.count(createGraph(TraverseParams.builder().setAfterTimestamp(beforeT0).setBeforeTimestamp(afterT0).build()).V(someIp.getId()).outE("resolve")));
}
use of no.mnemonic.act.platform.dao.api.record.ObjectRecord in project act-platform by mnemonic-no.
the class GuavaBackedObjectResolverTest method testGetObjectByIdFound.
@Test
public void testGetObjectByIdFound() {
UUID id = UUID.randomUUID();
when(objectManager.getObject(any())).thenReturn(new ObjectEntity());
when(objectRecordConverter.fromEntity(any())).thenReturn(new ObjectRecord());
assertNotNull(objectResolver.getObject(id));
verify(objectManager).getObject(id);
verify(objectRecordConverter).fromEntity(notNull());
}
use of no.mnemonic.act.platform.dao.api.record.ObjectRecord in project act-platform by mnemonic-no.
the class GuavaBackedObjectResolverTest method testGetObjectByIdFoundCached.
@Test
public void testGetObjectByIdFoundCached() {
UUID id = UUID.randomUUID();
when(objectManager.getObject(any())).thenReturn(new ObjectEntity());
when(objectRecordConverter.fromEntity(any())).then(i -> new ObjectRecord());
assertSame(objectResolver.getObject(id), objectResolver.getObject(id));
verify(objectManager).getObject(id);
verify(objectRecordConverter).fromEntity(notNull());
}
Aggregations