
com.automationrockstars.gir.data.impl.SimpleTestDataPool Maven / Gradle / Ivy
The newest version!
/*
*
*/
package com.automationrockstars.gir.data.impl;
import com.automationrockstars.gir.data.*;
import com.google.common.collect.Lists;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
public class SimpleTestDataPool implements TestDataPool {
private final String name;
private final List services = Lists.newArrayList();
public SimpleTestDataPool(String poolName) {
this.name = poolName;
services.addAll(TestDataServiceRegistry.services());
}
@Override
public String poolName() {
return name;
}
@Override
public void loadFrom(String location) {
for (TestDataService service : services) {
service.loadFrom(location);
}
}
@Override
public void loadFrom(String... locations) {
for (String location : locations) {
loadFrom(location);
}
}
@Override
public void close() {
for (TestDataService service : services) {
try {
service.close();
} catch (IOException e) {
}
}
TestDataServices.removePool(name);
}
@Override
public TestData testData(Class clazz) {
return testData(clazz, true);
}
@Override
public TestData exclusiveTestData(Class clazz) {
return testData(clazz, false);
}
public TestData testData(Class clazz, boolean shared) {
TestData result = null;
Iterator servicesToCheck = services.iterator();
TestDataService serviceToCheck;
while (result == null && servicesToCheck.hasNext() && ((serviceToCheck = servicesToCheck.next()) != null)) {
result = serviceToCheck.provide(SimpleTestData.NAME, shared, clazz);
}
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy