All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.automationrockstars.gir.data.TestDataServices Maven / Gradle / Ivy

The newest version!
/*
 * 
 */

package com.automationrockstars.gir.data;

import com.automationrockstars.gir.data.impl.SimpleTestDataPool;
import com.google.common.collect.Maps;

import java.util.concurrent.ConcurrentMap;

public class TestDataServices {


    private static final ConcurrentMap POOLS = Maps.newConcurrentMap();
    private static final String GLOBAL_POOL = "GLOBAL";


    public static synchronized TestDataPool pool(String poolName) {
        TestDataPool pool = POOLS.get(poolName);
        if (pool == null) {
            pool = new SimpleTestDataPool(poolName);
            POOLS.put(poolName, pool);
        }
        return pool;
    }

    public static TestDataPool pool() {
        return pool(GLOBAL_POOL);
    }

    public static synchronized void loadFrom(String jsonFile) {
        pool().loadFrom(jsonFile);
    }


    public static void close() {
        pool().close();
        for (TestDataPool pool : POOLS.values()) {
            pool.close();
        }
        POOLS.clear();
    }

    public static void removePool(String poolName){
        POOLS.remove(poolName);
    }


    public static  TestData testData(Class clazz) {
        return pool().testData(clazz);
    }

    public static  TestData exclusiveTestData(Class clazz) {
        return pool().exclusiveTestData(clazz);
    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy