mirror of
https://github.com/elisspace/autopsy.git
synced 2026-09-03 14:30:01 +00:00
fixed all the tests
This commit is contained in:
@@ -86,7 +86,7 @@ public class IngestedWithHashAndFileTypeInterCaseTests extends NbTestCase {
|
||||
Map<Long, String> dataSources = this.utils.getDataSourceMap();
|
||||
|
||||
//note that the params false and false are presently meaningless because that feature is not supported yet
|
||||
AbstractCommonAttributeSearcher builder = new AllInterCaseCommonAttributeSearcher(dataSources, false, false);
|
||||
AbstractCommonAttributeSearcher builder = new AllInterCaseCommonAttributeSearcher(dataSources, false, false, 0);
|
||||
|
||||
CommonAttributeSearchResults metadata = builder.findFiles();
|
||||
|
||||
@@ -139,7 +139,7 @@ public class IngestedWithHashAndFileTypeInterCaseTests extends NbTestCase {
|
||||
|
||||
int matchesMustAlsoBeFoundInThisCase = this.utils.getCaseMap().get(CASE2);
|
||||
|
||||
AbstractCommonAttributeSearcher builder = new SingleInterCaseCommonAttributeSearcher(matchesMustAlsoBeFoundInThisCase, dataSources, false, false);
|
||||
AbstractCommonAttributeSearcher builder = new SingleInterCaseCommonAttributeSearcher(matchesMustAlsoBeFoundInThisCase, dataSources, false, false, 0);
|
||||
|
||||
CommonAttributeSearchResults metadata = builder.findFiles();
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ public class IngestedWithHashAndFileTypeIntraCaseTests extends NbTestCase {
|
||||
try {
|
||||
Map<Long, String> dataSources = this.utils.getDataSourceMap();
|
||||
|
||||
AbstractCommonAttributeSearcher allSourcesBuilder = new AllIntraCaseCommonAttributeSearcher(dataSources, false, false);
|
||||
AbstractCommonAttributeSearcher allSourcesBuilder = new AllIntraCaseCommonAttributeSearcher(dataSources, false, false, 0);
|
||||
CommonAttributeSearchResults metadata = allSourcesBuilder.findFiles();
|
||||
|
||||
Map<Long, String> objectIdToDataSource = IntraCaseTestUtils.mapFileInstancesToDataSources(metadata);
|
||||
@@ -140,7 +140,7 @@ public class IngestedWithHashAndFileTypeIntraCaseTests extends NbTestCase {
|
||||
try {
|
||||
Map<Long, String> dataSources = this.utils.getDataSourceMap();
|
||||
|
||||
AbstractCommonAttributeSearcher allSourcesBuilder = new AllIntraCaseCommonAttributeSearcher(dataSources, true, false);
|
||||
AbstractCommonAttributeSearcher allSourcesBuilder = new AllIntraCaseCommonAttributeSearcher(dataSources, true, false, 0);
|
||||
CommonAttributeSearchResults metadata = allSourcesBuilder.findFiles();
|
||||
|
||||
Map<Long, String> objectIdToDataSource = mapFileInstancesToDataSources(metadata);
|
||||
@@ -181,7 +181,7 @@ public class IngestedWithHashAndFileTypeIntraCaseTests extends NbTestCase {
|
||||
try {
|
||||
Map<Long, String> dataSources = this.utils.getDataSourceMap();
|
||||
|
||||
AbstractCommonAttributeSearcher allSourcesBuilder = new AllIntraCaseCommonAttributeSearcher(dataSources, false, true);
|
||||
AbstractCommonAttributeSearcher allSourcesBuilder = new AllIntraCaseCommonAttributeSearcher(dataSources, false, true, 0);
|
||||
CommonAttributeSearchResults metadata = allSourcesBuilder.findFiles();
|
||||
|
||||
Map<Long, String> objectIdToDataSource = mapFileInstancesToDataSources(metadata);
|
||||
@@ -223,7 +223,7 @@ public class IngestedWithHashAndFileTypeIntraCaseTests extends NbTestCase {
|
||||
Map<Long, String> dataSources = this.utils.getDataSourceMap();
|
||||
Long first = getDataSourceIdByName(SET1, dataSources);
|
||||
|
||||
AbstractCommonAttributeSearcher singleSourceBuilder = new SingleIntraCaseCommonAttributeSearcher(first, dataSources, false, false);
|
||||
AbstractCommonAttributeSearcher singleSourceBuilder = new SingleIntraCaseCommonAttributeSearcher(first, dataSources, false, false, 0);
|
||||
CommonAttributeSearchResults metadata = singleSourceBuilder.findFiles();
|
||||
|
||||
Map<Long, String> objectIdToDataSource = mapFileInstancesToDataSources(metadata);
|
||||
@@ -265,7 +265,7 @@ public class IngestedWithHashAndFileTypeIntraCaseTests extends NbTestCase {
|
||||
Map<Long, String> dataSources = this.utils.getDataSourceMap();
|
||||
Long first = getDataSourceIdByName(SET1, dataSources);
|
||||
|
||||
AbstractCommonAttributeSearcher singleSourceBuilder = new SingleIntraCaseCommonAttributeSearcher(first, dataSources, true, false);
|
||||
AbstractCommonAttributeSearcher singleSourceBuilder = new SingleIntraCaseCommonAttributeSearcher(first, dataSources, true, false, 0);
|
||||
CommonAttributeSearchResults metadata = singleSourceBuilder.findFiles();
|
||||
|
||||
Map<Long, String> objectIdToDataSource = mapFileInstancesToDataSources(metadata);
|
||||
@@ -307,7 +307,7 @@ public class IngestedWithHashAndFileTypeIntraCaseTests extends NbTestCase {
|
||||
Map<Long, String> dataSources = this.utils.getDataSourceMap();
|
||||
Long first = getDataSourceIdByName(SET1, dataSources);
|
||||
|
||||
AbstractCommonAttributeSearcher singleSourceBuilder = new SingleIntraCaseCommonAttributeSearcher(first, dataSources, false, true);
|
||||
AbstractCommonAttributeSearcher singleSourceBuilder = new SingleIntraCaseCommonAttributeSearcher(first, dataSources, false, true, 0);
|
||||
CommonAttributeSearchResults metadata = singleSourceBuilder.findFiles();
|
||||
|
||||
Map<Long, String> objectIdToDataSource = mapFileInstancesToDataSources(metadata);
|
||||
@@ -349,7 +349,7 @@ public class IngestedWithHashAndFileTypeIntraCaseTests extends NbTestCase {
|
||||
Map<Long, String> dataSources = this.utils.getDataSourceMap();
|
||||
Long second = getDataSourceIdByName(SET2, dataSources);
|
||||
|
||||
AbstractCommonAttributeSearcher singleSourceBuilder = new SingleIntraCaseCommonAttributeSearcher(second, dataSources, false, false);
|
||||
AbstractCommonAttributeSearcher singleSourceBuilder = new SingleIntraCaseCommonAttributeSearcher(second, dataSources, false, false, 0);
|
||||
CommonAttributeSearchResults metadata = singleSourceBuilder.findFiles();
|
||||
|
||||
Map<Long, String> objectIdToDataSource = mapFileInstancesToDataSources(metadata);
|
||||
@@ -390,7 +390,7 @@ public class IngestedWithHashAndFileTypeIntraCaseTests extends NbTestCase {
|
||||
Map<Long, String> dataSources = this.utils.getDataSourceMap();
|
||||
Long last = getDataSourceIdByName(SET4, dataSources);
|
||||
|
||||
AbstractCommonAttributeSearcher singleSourceBuilder = new SingleIntraCaseCommonAttributeSearcher(last, dataSources, false, false);
|
||||
AbstractCommonAttributeSearcher singleSourceBuilder = new SingleIntraCaseCommonAttributeSearcher(last, dataSources, false, false, 0);
|
||||
CommonAttributeSearchResults metadata = singleSourceBuilder.findFiles();
|
||||
|
||||
Map<Long, String> objectIdToDataSource = mapFileInstancesToDataSources(metadata);
|
||||
@@ -431,7 +431,7 @@ public class IngestedWithHashAndFileTypeIntraCaseTests extends NbTestCase {
|
||||
Map<Long, String> dataSources = this.utils.getDataSourceMap();
|
||||
Long third = getDataSourceIdByName(SET3, dataSources);
|
||||
|
||||
AbstractCommonAttributeSearcher singleSourceBuilder = new SingleIntraCaseCommonAttributeSearcher(third, dataSources, false, false);
|
||||
AbstractCommonAttributeSearcher singleSourceBuilder = new SingleIntraCaseCommonAttributeSearcher(third, dataSources, false, false, 0);
|
||||
CommonAttributeSearchResults metadata = singleSourceBuilder.findFiles();
|
||||
|
||||
Map<Long, String> objectIdToDataSource = mapFileInstancesToDataSources(metadata);
|
||||
|
||||
@@ -101,7 +101,7 @@ public class IngestedWithNoFileTypesIntraCaseTests extends NbTestCase {
|
||||
try {
|
||||
Map<Long, String> dataSources = this.utils.getDataSourceMap();
|
||||
|
||||
IntraCaseCommonAttributeSearcher allSourcesBuilder = new AllIntraCaseCommonAttributeSearcher(dataSources, true, false);
|
||||
IntraCaseCommonAttributeSearcher allSourcesBuilder = new AllIntraCaseCommonAttributeSearcher(dataSources, true, false, 0);
|
||||
CommonAttributeSearchResults metadata = allSourcesBuilder.findFiles();
|
||||
|
||||
Map<Long, String> objectIdToDataSource = IntraCaseTestUtils.mapFileInstancesToDataSources(metadata);
|
||||
@@ -125,7 +125,7 @@ public class IngestedWithNoFileTypesIntraCaseTests extends NbTestCase {
|
||||
Map<Long, String> dataSources = this.utils.getDataSourceMap();
|
||||
Long third = IntraCaseTestUtils.getDataSourceIdByName(IntraCaseTestUtils.SET3, dataSources);
|
||||
|
||||
IntraCaseCommonAttributeSearcher singleSourceBuilder = new SingleIntraCaseCommonAttributeSearcher(third, dataSources, true, false);
|
||||
IntraCaseCommonAttributeSearcher singleSourceBuilder = new SingleIntraCaseCommonAttributeSearcher(third, dataSources, true, false, 0);
|
||||
CommonAttributeSearchResults metadata = singleSourceBuilder.findFiles();
|
||||
|
||||
Map<Long, String> objectIdToDataSource = IntraCaseTestUtils.mapFileInstancesToDataSources(metadata);
|
||||
|
||||
@@ -307,67 +307,73 @@ class InterCaseTestUtils {
|
||||
//TODO refactor
|
||||
static boolean verifyInstanceExistanceAndCount(CommonAttributeSearchResults searchDomain, String fileName, String dataSource, String crCase, int instanceCount){
|
||||
|
||||
int tally = 0;
|
||||
|
||||
for(Map.Entry<Integer, List<CommonAttributeValue>> entry : searchDomain.getMetadata().entrySet()){
|
||||
try {
|
||||
int tally = 0;
|
||||
|
||||
for(CommonAttributeValue value : entry.getValue()){
|
||||
for(Map.Entry<Integer, List<CommonAttributeValue>> entry : searchDomain.getMetadata().entrySet()){
|
||||
|
||||
for(AbstractCommonAttributeInstance commonAttribute : value.getInstances()){
|
||||
for(CommonAttributeValue value : entry.getValue()){
|
||||
|
||||
if(commonAttribute instanceof CentralRepoCommonAttributeInstance){
|
||||
CentralRepoCommonAttributeInstance results = (CentralRepoCommonAttributeInstance) commonAttribute;
|
||||
for (DisplayableItemNode din : results.generateNodes()){
|
||||
|
||||
if(din instanceof CentralRepoCommonAttributeInstanceNode){
|
||||
for(AbstractCommonAttributeInstance commonAttribute : value.getInstances()){
|
||||
|
||||
if(commonAttribute instanceof CentralRepoCommonAttributeInstance){
|
||||
CentralRepoCommonAttributeInstance results = (CentralRepoCommonAttributeInstance) commonAttribute;
|
||||
for (DisplayableItemNode din : results.generateNodes()){
|
||||
|
||||
CentralRepoCommonAttributeInstanceNode node = (CentralRepoCommonAttributeInstanceNode) din;
|
||||
CorrelationAttributeInstance instance = node.getCorrelationAttributeInstance();
|
||||
if(din instanceof CentralRepoCommonAttributeInstanceNode){
|
||||
|
||||
CentralRepoCommonAttributeInstanceNode node = (CentralRepoCommonAttributeInstanceNode) din;
|
||||
CorrelationAttributeInstance instance = node.getCorrelationAttributeInstance();
|
||||
|
||||
final String fullPath = instance.getFilePath();
|
||||
final File testFile = new File(fullPath);
|
||||
|
||||
final String testCaseName = instance.getCorrelationCase().getDisplayName();
|
||||
|
||||
final String testFileName = testFile.getName();
|
||||
|
||||
final String testDataSource = instance.getCorrelationDataSource().getName();
|
||||
|
||||
boolean sameFileName = testFileName.equalsIgnoreCase(fileName);
|
||||
boolean sameDataSource = testDataSource.equalsIgnoreCase(dataSource);
|
||||
boolean sameCrCase = testCaseName.equalsIgnoreCase(crCase);
|
||||
|
||||
if( sameFileName && sameDataSource && sameCrCase){
|
||||
tally++;
|
||||
}
|
||||
}
|
||||
|
||||
final String fullPath = instance.getFilePath();
|
||||
final File testFile = new File(fullPath);
|
||||
|
||||
final String testCaseName = instance.getCorrelationCase().getDisplayName();
|
||||
|
||||
final String testFileName = testFile.getName();
|
||||
|
||||
final String testDataSource = instance.getCorrelationDataSource().getName();
|
||||
|
||||
boolean sameFileName = testFileName.equalsIgnoreCase(fileName);
|
||||
boolean sameDataSource = testDataSource.equalsIgnoreCase(dataSource);
|
||||
boolean sameCrCase = testCaseName.equalsIgnoreCase(crCase);
|
||||
|
||||
if( sameFileName && sameDataSource && sameCrCase){
|
||||
tally++;
|
||||
}
|
||||
}
|
||||
|
||||
if(din instanceof CaseDBCommonAttributeInstanceNode){
|
||||
|
||||
CaseDBCommonAttributeInstanceNode node = (CaseDBCommonAttributeInstanceNode) din;
|
||||
AbstractFile file = node.getContent();
|
||||
|
||||
final String testFileName = file.getName();
|
||||
final String testCaseName = node.getCase();
|
||||
final String testDataSource = node.getDataSource();
|
||||
|
||||
boolean sameFileName = testFileName.equalsIgnoreCase(fileName);
|
||||
boolean sameCaseName = testCaseName.equalsIgnoreCase(crCase);
|
||||
boolean sameDataSource = testDataSource.equalsIgnoreCase(dataSource);
|
||||
|
||||
if(sameFileName && sameDataSource && sameCaseName){
|
||||
tally++;
|
||||
if(din instanceof CaseDBCommonAttributeInstanceNode){
|
||||
|
||||
CaseDBCommonAttributeInstanceNode node = (CaseDBCommonAttributeInstanceNode) din;
|
||||
AbstractFile file = node.getContent();
|
||||
|
||||
final String testFileName = file.getName();
|
||||
final String testCaseName = node.getCase();
|
||||
final String testDataSource = node.getDataSource();
|
||||
|
||||
boolean sameFileName = testFileName.equalsIgnoreCase(fileName);
|
||||
boolean sameCaseName = testCaseName.equalsIgnoreCase(crCase);
|
||||
boolean sameDataSource = testDataSource.equalsIgnoreCase(dataSource);
|
||||
|
||||
if(sameFileName && sameDataSource && sameCaseName){
|
||||
tally++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Assert.fail("Unable to cast AbstractCommonAttributeInstanceNode to InterCaseCommonAttributeSearchResults.");
|
||||
}
|
||||
} else {
|
||||
Assert.fail("Unable to cast AbstractCommonAttributeInstanceNode to InterCaseCommonAttributeSearchResults.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tally == instanceCount;
|
||||
} catch (EamDbException ex) {
|
||||
Exceptions.printStackTrace(ex);
|
||||
Assert.fail(ex);
|
||||
return false;
|
||||
}
|
||||
|
||||
return tally == instanceCount;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.python.icu.impl.Assert;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.casemodule.ImageDSProcessor;
|
||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException;
|
||||
import org.sleuthkit.autopsy.commonfilesearch.AbstractCommonAttributeInstance;
|
||||
import org.sleuthkit.autopsy.commonfilesearch.CommonAttributeSearchResults;
|
||||
import org.sleuthkit.autopsy.commonfilesearch.DataSourceLoader;
|
||||
@@ -204,16 +205,22 @@ class IntraCaseTestUtils {
|
||||
*/
|
||||
static Map<Long, String> mapFileInstancesToDataSources(CommonAttributeSearchResults metadata) {
|
||||
Map<Long, String> instanceIdToDataSource = new HashMap<>();
|
||||
|
||||
for (Map.Entry<Integer, List<CommonAttributeValue>> entry : metadata.getMetadata().entrySet()) {
|
||||
for (CommonAttributeValue md : entry.getValue()) {
|
||||
for (AbstractCommonAttributeInstance fim : md.getInstances()) {
|
||||
instanceIdToDataSource.put(fim.getAbstractFileObjectId(), fim.getDataSource());
|
||||
|
||||
try {
|
||||
for (Map.Entry<Integer, List<CommonAttributeValue>> entry : metadata.getMetadata().entrySet()) {
|
||||
for (CommonAttributeValue md : entry.getValue()) {
|
||||
for (AbstractCommonAttributeInstance fim : md.getInstances()) {
|
||||
instanceIdToDataSource.put(fim.getAbstractFileObjectId(), fim.getDataSource());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return instanceIdToDataSource;
|
||||
} catch (EamDbException ex) {
|
||||
Exceptions.printStackTrace(ex);
|
||||
Assert.fail(ex);
|
||||
return instanceIdToDataSource;
|
||||
}
|
||||
|
||||
return instanceIdToDataSource;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ public class MatchesInAtLeastTwoSourcesIntraCaseTests extends NbTestCase {
|
||||
try {
|
||||
Map<Long, String> dataSources = this.utils.getDataSourceMap();
|
||||
|
||||
AbstractCommonAttributeSearcher allSourcesBuilder = new AllIntraCaseCommonAttributeSearcher(dataSources, false, false);
|
||||
AbstractCommonAttributeSearcher allSourcesBuilder = new AllIntraCaseCommonAttributeSearcher(dataSources, false, false, 0);
|
||||
CommonAttributeSearchResults metadata = allSourcesBuilder.findFiles();
|
||||
|
||||
Map<Long, String> objectIdToDataSource = IntraCaseTestUtils.mapFileInstancesToDataSources(metadata);
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.netbeans.junit.NbTestCase;
|
||||
import org.openide.util.Exceptions;
|
||||
import org.python.icu.impl.Assert;
|
||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException;
|
||||
import org.sleuthkit.autopsy.commonfilesearch.AllIntraCaseCommonAttributeSearcher;
|
||||
import org.sleuthkit.autopsy.commonfilesearch.CommonAttributeSearchResults;
|
||||
import org.sleuthkit.autopsy.commonfilesearch.IntraCaseCommonAttributeSearcher;
|
||||
@@ -81,7 +80,7 @@ public class UningestedCasesIntraCaseTests extends NbTestCase {
|
||||
try {
|
||||
Map<Long, String> dataSources = this.utils.getDataSourceMap();
|
||||
|
||||
IntraCaseCommonAttributeSearcher allSourcesBuilder = new AllIntraCaseCommonAttributeSearcher(dataSources, false, false);
|
||||
IntraCaseCommonAttributeSearcher allSourcesBuilder = new AllIntraCaseCommonAttributeSearcher(dataSources, false, false, 0);
|
||||
CommonAttributeSearchResults metadata = allSourcesBuilder.findFiles();
|
||||
|
||||
int resultCount = metadata.size();
|
||||
@@ -101,7 +100,7 @@ public class UningestedCasesIntraCaseTests extends NbTestCase {
|
||||
Map<Long, String> dataSources = this.utils.getDataSourceMap();
|
||||
Long first = getDataSourceIdByName(SET1, dataSources);
|
||||
|
||||
IntraCaseCommonAttributeSearcher singleSourceBuilder = new SingleIntraCaseCommonAttributeSearcher(first, dataSources, false, false);
|
||||
IntraCaseCommonAttributeSearcher singleSourceBuilder = new SingleIntraCaseCommonAttributeSearcher(first, dataSources, false, false, 0);
|
||||
CommonAttributeSearchResults metadata = singleSourceBuilder.findFiles();
|
||||
|
||||
int resultCount = metadata.size();
|
||||
|
||||
Reference in New Issue
Block a user