def test_execute(sample, class_instance):
        # Imports required to execute the sample
        from assemblyline_v4_service.common.task import Task
        from assemblyline.odm.messages.task import Task as ServiceTask
        from assemblyline_v4_service.common.request import ServiceRequest

        # Creating the required objects for execution
        service_task = ServiceTask(sample1)
        task = Task(service_task)
        class_instance._task = task
        service_request = ServiceRequest(task)

        # Actually executing the sample
        task.service_config = {"resubmit_apk_as_jar": False}
        class_instance.execute(service_request)

        # Get the result of execute() from the test method
        test_result = task.get_service_result()

        # Get the assumed "correct" result of the sample
        correct_result_path = os.path.join(TEST_DIR, "results", task.file_name + ".json")
        with open(correct_result_path, "r") as f:
            correct_result = json.loads(f.read())
        f.close()

        # Assert that the appropriate sections of the dict are equal

        # Avoiding date in the response
        test_result_response = test_result.pop("response")
        correct_result_response = correct_result.pop("response")
        assert test_result == correct_result

        # Comparing everything in the response except for the date
        test_result_response["milestones"].pop("service_completed")
        correct_result_response["milestones"].pop("service_completed")
        assert test_result_response == correct_result_response
    def test_execute(sample, intezer_static_class_instance,
                     dummy_api_interface_class, dummy_get_response_class,
                     mocker):
        from assemblyline_v4_service.common.task import Task
        from assemblyline.odm.messages.task import Task as ServiceTask
        from assemblyline_v4_service.common.request import ServiceRequest
        from json import loads
        from intezer_static import ALIntezerApi

        mocker.patch.object(intezer_static_class_instance,
                            "get_api_interface",
                            return_value=dummy_api_interface_class)
        intezer_static_class_instance.start()

        service_task = ServiceTask(sample)
        task = Task(service_task)
        task.service_config = {
            "analysis_id": "",
        }
        intezer_static_class_instance._task = task
        service_request = ServiceRequest(task)
        intezer_static_class_instance.config["private_only"] = False

        mocker.patch.object(ALIntezerApi,
                            "get_latest_analysis",
                            return_value={"analysis_id": "blah"})
        mocker.patch.object(ALIntezerApi,
                            "analyze_by_file",
                            return_value="blah")
        mocker.patch.object(ALIntezerApi,
                            "get_iocs",
                            return_value={
                                "files": [],
                                "network": []
                            })
        mocker.patch.object(ALIntezerApi, "get_dynamic_ttps", return_value=[])
        mocker.patch.object(ALIntezerApi,
                            "get_sub_analyses_by_id",
                            return_value=[])

        # Actually executing the sample
        intezer_static_class_instance.execute(service_request)

        # Get the result of execute() from the test method
        test_result = task.get_service_result()

        # Get the assumed "correct" result of the sample
        correct_result_path = os.path.join(TEST_DIR, "results",
                                           task.file_name + ".json")
        with open(correct_result_path, "r") as f:
            correct_result = loads(f.read())
        f.close()

        # Assert that the appropriate sections of the dict are equal

        # Avoiding unique items in the response
        test_result_response = test_result.pop("response")
        correct_result_response = correct_result.pop("response")
        assert test_result == correct_result

        # Comparing everything in the response except for the service_completed and the output.json supplementary
        test_result_response["milestones"].pop("service_completed")
        correct_result_response["milestones"].pop("service_completed")
        correct_result_response.pop("supplementary")
        test_result_response.pop("supplementary")
        correct_result_response.pop("service_context")
        test_result_response.pop("service_context")
        assert test_result_response == correct_result_response

        # Code coverage
        task.service_config = {
            "analysis_id": "blah",
        }
        intezer_static_class_instance._task = task
        service_request = ServiceRequest(task)
        intezer_static_class_instance.execute(service_request)

        task.service_config = {"analysis_id": ""}
        intezer_static_class_instance.config["is_on_premise"] = False
        mocker.patch.object(ALIntezerApi,
                            "get_latest_analysis",
                            return_value={"verdict": "not_supported"})
        mocker.patch.object(ALIntezerApi, "get_dynamic_ttps", return_value=[])
        intezer_static_class_instance.execute(service_request)

        mocker.patch.object(ALIntezerApi,
                            "get_latest_analysis",
                            return_value={"verdict": "failed"})
        intezer_static_class_instance.execute(service_request)