/*
 * 
 * Autopsy Forensic Browser
 * 
 * Copyright 2018 Basis Technology Corp.
 * Contact: carrier <at> sleuthkit <dot> org
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.sleuthkit.autopsy.commonfilessearch;

import junit.framework.Test;
import org.netbeans.junit.NbModuleSuite;
import org.netbeans.junit.NbTestCase;
import org.openide.util.Exceptions;
import org.python.icu.impl.Assert;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.datamodel.TskCoreException;

/**
 * If I use the search all cases option: One node for Hash A (1_1_A.jpg,
 * 1_2_A.jpg, 3_1_A.jpg) If I search for matches only in Case 1: One node for
 * Hash A (1_1_A.jpg, 1_2_A.jpg, 3_1_A.jpg) If I search for matches only in Case
 * 2: No matches If I only search in the current case (existing mode), allowing
 * all data sources: One node for Hash C (3_1_C.jpg, 3_2_C.jpg)
 */
public class IngestedWithHashAndFileTypeInterCaseTests extends NbTestCase {
    
    private final InterCaseUtils utils;
    
    private Case currentCase;
    
    public static Test suite() {
        NbModuleSuite.Configuration conf = NbModuleSuite.createConfiguration(IngestedWithHashAndFileTypeInterCaseTests.class).
                clusters(".*").
                enableModules(".*");
        return conf.suite();
    }
    
    public IngestedWithHashAndFileTypeInterCaseTests(String name) {
        super(name);
        this.utils = new InterCaseUtils(this);
    }
    
    @Override
    public void setUp(){
        try {
            this.currentCase = this.utils.createCases(this.utils.getIngestSettingsForHashAndFileType(), InterCaseUtils.CASE1);
        } catch (TskCoreException ex) {
            Exceptions.printStackTrace(ex);
            Assert.fail(ex);
        }
    }

    @Override
    public void tearDown(){
        this.utils.tearDown();
    }
}

@@ -733,16 +733,68 @@
 earch;%0A%0A
+import java.sql.SQLException;%0Aimport java.util.Map;%0A
 import j
@@ -814,16 +814,16 @@
 k.Test;%0A
-
 import o
@@ -1006,24 +1006,383 @@
 odule.Case;%0A
+import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;%0Aimport org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException;%0Aimport org.sleuthkit.autopsy.commonfilesearch.AllCasesEamDbCommonFilesAlgorithm;%0Aimport org.sleuthkit.autopsy.commonfilesearch.CommonFilesMetadata;%0Aimport org.sleuthkit.autopsy.commonfilesearch.CommonFilesMetadataBuilder;%0A
 import org.s
@@ -2433,16 +2433,60 @@
   try %7B%0A
+            this.utils.enableCentralRepo();%0A
         
@@ -2621,23 +2621,16 @@
  catch (
-TskCore
 Exceptio
@@ -2765,24 +2765,24 @@
 tearDown()%7B%0A
-
         this
@@ -2806,10 +2806,824 @@
 ;%0A    %7D%0A
+    %0A    /**%0A     * Search All%0A     * %0A     * One node for Hash A (1_1_A.jpg, 1_2_A.jpg, 3_1_A.jpg)%0A     */%0A    public void testOne() %7B%0A        try %7B%0A            Map%3CLong, String%3E dataSources = this.utils.getDataSourceMap();%0A            %0A            CommonFilesMetadataBuilder builder = new AllCasesEamDbCommonFilesAlgorithm(dataSources, false, false);%0A            %0A            CommonFilesMetadata metadata = builder.findFiles();%0A            %0A            assertTrue(%22%22, metadata.size() != 0);%0A            %0A            %0A        %7D catch (Exception ex) %7B%0A            Exceptions.printStackTrace(ex); %0A            Assert.fail(ex);%0A        %7D%0A        %0A        %0A    %7D%0A    %0A    /**%0A     * Case1%0A     */%0A    public void testTwo()%7B%0A        %0A    %7D%0A    %0A    /**%0A     * Case2%0A     */%0A    public void testThree()%7B%0A        %0A    %7D%0A
 %7D%0A

test one stub