<commit_before>package workerinstance

import fake.Database
import org.openforis.sepal.component.workerinstance.WorkerInstanceComponent
import org.openforis.sepal.component.workerinstance.api.WorkerInstance
import org.openforis.sepal.component.workerinstance.command.ReleaseInstance
import org.openforis.sepal.component.workerinstance.command.RequestInstance
import org.openforis.sepal.event.Event
import org.openforis.sepal.event.HandlerRegistryEventDispatcher
import sandboxmanager.FakeClock
import spock.lang.Specification
import workersession.FakeBudgetChecker

abstract class AbstractWorkerInstanceTest extends Specification {
    final database = new Database()
    final eventDispatcher = new HandlerRegistryEventDispatcher()
    final instanceProvider = new FakeInstanceProvider()
    final instanceProvisioner = new FakeInstanceProvisioner()
    final budgetChecker = new FakeBudgetChecker()
    final clock = new FakeClock()
    final component = new WorkerInstanceComponent(
            database.dataSource,
            eventDispatcher,
            instanceProvider,
            instanceProvisioner,
            clock)

    final events = [] as List<Event>

    final testWorkerType = 'test-worker-type'
    final testInstanceType = 'test-instance-type'
    final testUsername = 'test-user'

    final WorkerInstance requestInstance(Map args = [:]) {
        component.submit(new RequestInstance(
                username: username(args),
                workerType: args.workerType ?: testWorkerType,
                instanceType: args.instanceType ?: testInstanceType
        ))
    }

    final void releaseInstance(WorkerInstance instance) {
        component.submit(new ReleaseInstance(instanceId: instance.id))
    }<commit_msg>Removed unused test dependency.<commit_after>package workerinstance

import fake.Database
import org.openforis.sepal.component.workerinstance.WorkerInstanceComponent
import org.openforis.sepal.component.workerinstance.api.WorkerInstance
import org.openforis.sepal.component.workerinstance.command.ReleaseInstance
import org.openforis.sepal.component.workerinstance.command.RequestInstance
import org.openforis.sepal.event.Event
import org.openforis.sepal.event.HandlerRegistryEventDispatcher
import sandboxmanager.FakeClock
import spock.lang.Specification
import workersession.FakeBudgetChecker

abstract class AbstractWorkerInstanceTest extends Specification {
    final database = new Database()
    final eventDispatcher = new HandlerRegistryEventDispatcher()
    final instanceProvider = new FakeInstanceProvider()
    final instanceProvisioner = new FakeInstanceProvisioner()
    final clock = new FakeClock()
    final component = new WorkerInstanceComponent(
            database.dataSource,
            eventDispatcher,
            instanceProvider,
            instanceProvisioner,
            clock)

    final events = [] as List<Event>

    final testWorkerType = 'test-worker-type'
    final testInstanceType = 'test-instance-type'
    final testUsername = 'test-user'

    final WorkerInstance requestInstance(Map args = [:]) {
        component.submit(new RequestInstance(
                username: username(args),
                workerType: args.workerType ?: testWorkerType,
                instanceType: args.instanceType ?: testInstanceType
        ))
    }

    final void releaseInstance(WorkerInstance instance) {
        component.submit(new ReleaseInstance(instanceId: instance.id))
    }
{'fraction_non_alphanumeric': 0.06998264893001735, 'fraction_numerical': 0.0, 'mean_word_length': 3.8310055865921786, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5567252', 'n_tokens_mistral': 871, 'n_tokens_neox': 846, 'n_words': 187}