Updating haverster
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-dashboard-harvester-se-plugin@179244 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
e63e4a65f1
commit
354bc153ce
|
@ -115,7 +115,7 @@ public class AccountingDataHarvesterPlugin extends Plugin<DataHarvestPluginDecla
|
||||||
return scopeDescriptor.get();
|
return scopeDescriptor.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final InheritableThreadLocal<ScopeDescriptor> scopeDescriptor = new InheritableThreadLocal<ScopeDescriptor>() {
|
public static final InheritableThreadLocal<ScopeDescriptor> scopeDescriptor = new InheritableThreadLocal<ScopeDescriptor>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ScopeDescriptor initialValue() {
|
protected ScopeDescriptor initialValue() {
|
||||||
|
|
|
@ -26,7 +26,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.gcube.accounting.accounting.summary.access.model.ScopeDescriptor;
|
import org.gcube.accounting.accounting.summary.access.model.ScopeDescriptor;
|
||||||
import org.gcube.accounting.accounting.summary.access.model.update.AccountingRecord;
|
import org.gcube.accounting.accounting.summary.access.model.update.AccountingRecord;
|
||||||
import org.gcube.common.encryption.StringEncrypter;
|
import org.gcube.common.encryption.encrypter.StringEncrypter;
|
||||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||||
import org.gcube.common.resources.gcore.ServiceEndpoint.Property;
|
import org.gcube.common.resources.gcore.ServiceEndpoint.Property;
|
||||||
|
@ -184,7 +184,7 @@ public class VREAccessesHarvester extends BasicHarvester {
|
||||||
for(String view : viewIDs) {
|
for(String view : viewIDs) {
|
||||||
logger.info("Getting data from Google Analytics for viewid: " + view);
|
logger.info("Getting data from Google Analytics for viewid: " + view);
|
||||||
// Create the ReportRequest object.
|
// Create the ReportRequest object.
|
||||||
ReportRequest request = new ReportRequest().setViewId(view).setDateRanges(Arrays.asList(dateRange))
|
ReportRequest request = new ReportRequest().setViewId(view.trim()).setDateRanges(Arrays.asList(dateRange))
|
||||||
.setMetrics(Arrays.asList(sessions)).setDimensions(Arrays.asList(pageTitle));
|
.setMetrics(Arrays.asList(sessions)).setDimensions(Arrays.asList(pageTitle));
|
||||||
|
|
||||||
ArrayList<ReportRequest> requests = new ArrayList<ReportRequest>();
|
ArrayList<ReportRequest> requests = new ArrayList<ReportRequest>();
|
||||||
|
|
|
@ -35,7 +35,11 @@ public class TagMeMethodInvocationHarvester extends BasicHarvester {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(TagMeMethodInvocationHarvester.class);
|
private static Logger logger = LoggerFactory.getLogger(TagMeMethodInvocationHarvester.class);
|
||||||
|
|
||||||
public static final String TAG_METHOD = "/tag";
|
public static final String SWAT = "SWAT";
|
||||||
|
public static final String TAGME = "TagMe";
|
||||||
|
public static final String WAT = "WAT";
|
||||||
|
|
||||||
|
public static String[] SERVICE_NAMES = {SWAT,TAGME,WAT};
|
||||||
|
|
||||||
public TagMeMethodInvocationHarvester(Date start, Date end) throws Exception {
|
public TagMeMethodInvocationHarvester(Date start, Date end) throws Exception {
|
||||||
super(start, end);
|
super(start, end);
|
||||||
|
@ -51,20 +55,20 @@ public class TagMeMethodInvocationHarvester extends BasicHarvester {
|
||||||
TemporalConstraint temporalConstraint = new TemporalConstraint(start.getTime(), end.getTime(),
|
TemporalConstraint temporalConstraint = new TemporalConstraint(start.getTime(), end.getTime(),
|
||||||
AggregationMode.MONTHLY);
|
AggregationMode.MONTHLY);
|
||||||
|
|
||||||
List<Filter> filters = new ArrayList<>();
|
|
||||||
filters.add(new Filter(ServiceUsageRecord.CALLED_METHOD, TAG_METHOD));
|
|
||||||
|
|
||||||
String context = Utils.getCurrentContext();
|
|
||||||
|
|
||||||
List<String> contexts = new ArrayList<>();
|
List<String> contexts = new ArrayList<>();
|
||||||
|
String context = Utils.getCurrentContext();
|
||||||
contexts.add(context);
|
contexts.add(context);
|
||||||
|
|
||||||
|
long numberOfInvocation = 0;
|
||||||
|
|
||||||
|
for(String serviceName : SERVICE_NAMES) {
|
||||||
|
|
||||||
|
List<Filter> filters = new ArrayList<>();
|
||||||
|
filters.add(new Filter(ServiceUsageRecord.SERVICE_NAME, serviceName));
|
||||||
|
|
||||||
SortedMap<Filter,SortedMap<Calendar,Info>> result = accountingPersistenceQuery.getContextTimeSeries(
|
SortedMap<Filter,SortedMap<Calendar,Info>> result = accountingPersistenceQuery.getContextTimeSeries(
|
||||||
AggregatedServiceUsageRecord.class, temporalConstraint, filters, contexts, true);
|
AggregatedServiceUsageRecord.class, temporalConstraint, filters, contexts, true);
|
||||||
|
|
||||||
ScopeDescriptor scopeDescriptor = AccountingDataHarvesterPlugin.getScopeDescriptor();
|
|
||||||
Dimension dimension = getDimension(HarvestedDataKey.METHOD_INVOCATIONS);
|
|
||||||
|
|
||||||
if(result != null) {
|
if(result != null) {
|
||||||
for(Filter filter : result.keySet()) {
|
for(Filter filter : result.keySet()) {
|
||||||
SortedMap<Calendar,Info> infoMap = result.get(filter);
|
SortedMap<Calendar,Info> infoMap = result.get(filter);
|
||||||
|
@ -72,21 +76,25 @@ public class TagMeMethodInvocationHarvester extends BasicHarvester {
|
||||||
Calendar calendar = DateUtils.dateToCalendar(start);
|
Calendar calendar = DateUtils.dateToCalendar(start);
|
||||||
|
|
||||||
Info info = infoMap.get(calendar);
|
Info info = infoMap.get(calendar);
|
||||||
logger.debug("{} : {}", DateUtils.format(calendar), info);
|
logger.debug("Service {} - {} : {}", serviceName, DateUtils.format(calendar), info);
|
||||||
|
|
||||||
JSONObject jsonObject = info.getValue();
|
JSONObject jsonObject = info.getValue();
|
||||||
long numberOfInvocation = jsonObject.getLong(AggregatedUsageRecord.OPERATION_COUNT);
|
numberOfInvocation += jsonObject.getLong(AggregatedUsageRecord.OPERATION_COUNT);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
logger.error("No data found in {} for service {}.", context, serviceName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ScopeDescriptor scopeDescriptor = AccountingDataHarvesterPlugin.getScopeDescriptor();
|
||||||
|
Dimension dimension = getDimension(HarvestedDataKey.METHOD_INVOCATIONS);
|
||||||
|
|
||||||
AccountingRecord ar = new AccountingRecord(scopeDescriptor, instant, dimension, numberOfInvocation);
|
AccountingRecord ar = new AccountingRecord(scopeDescriptor, instant, dimension, numberOfInvocation);
|
||||||
logger.debug("{} : {}", ar.getDimension().getId(), ar.getMeasure());
|
logger.debug("{} : {}", ar.getDimension().getId(), ar.getMeasure());
|
||||||
accountingRecords.add(ar);
|
accountingRecords.add(ar);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
logger.error("No data found.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return accountingRecords;
|
return accountingRecords;
|
||||||
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
|
|
|
@ -18,6 +18,8 @@ import org.gcube.accounting.accounting.summary.access.AccountingDao;
|
||||||
import org.gcube.accounting.accounting.summary.access.model.ScopeDescriptor;
|
import org.gcube.accounting.accounting.summary.access.model.ScopeDescriptor;
|
||||||
import org.gcube.accounting.accounting.summary.access.model.internal.Dimension;
|
import org.gcube.accounting.accounting.summary.access.model.internal.Dimension;
|
||||||
import org.gcube.accounting.accounting.summary.access.model.update.AccountingRecord;
|
import org.gcube.accounting.accounting.summary.access.model.update.AccountingRecord;
|
||||||
|
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
||||||
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
import org.gcube.common.scope.impl.ScopeBean;
|
import org.gcube.common.scope.impl.ScopeBean;
|
||||||
import org.gcube.common.scope.impl.ScopeBean.Type;
|
import org.gcube.common.scope.impl.ScopeBean.Type;
|
||||||
import org.gcube.dataharvest.datamodel.HarvestedDataKey;
|
import org.gcube.dataharvest.datamodel.HarvestedDataKey;
|
||||||
|
@ -32,7 +34,6 @@ import org.gcube.dataharvest.utils.AggregationType;
|
||||||
import org.gcube.dataharvest.utils.ContextAuthorization;
|
import org.gcube.dataharvest.utils.ContextAuthorization;
|
||||||
import org.gcube.dataharvest.utils.ContextTest;
|
import org.gcube.dataharvest.utils.ContextTest;
|
||||||
import org.gcube.dataharvest.utils.DateUtils;
|
import org.gcube.dataharvest.utils.DateUtils;
|
||||||
import org.gcube.dataharvest.utils.Utils;
|
|
||||||
import org.gcube.resourcemanagement.support.server.managers.context.ContextManager;
|
import org.gcube.resourcemanagement.support.server.managers.context.ContextManager;
|
||||||
import org.gcube.vremanagement.executor.api.rest.SmartExecutor;
|
import org.gcube.vremanagement.executor.api.rest.SmartExecutor;
|
||||||
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
|
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
|
||||||
|
@ -48,8 +49,11 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(AccountingDataHarvesterPluginTest.class);
|
private static Logger logger = LoggerFactory.getLogger(AccountingDataHarvesterPluginTest.class);
|
||||||
|
|
||||||
public static final String SO_BIG_DATA_CONTEXT = "/d4science.research-infrastructures.eu/SoBigData";
|
public static final String ROOT = "/d4science.research-infrastructures.eu";
|
||||||
|
public static final String SO_BIG_VO = "/d4science.research-infrastructures.eu/SoBigData";
|
||||||
|
|
||||||
|
public static final String TAGME_VRE = "/d4science.research-infrastructures.eu/SoBigData/TagMe";
|
||||||
|
public static final String STOCK_ASSESMENT_VRE = "/d4science.research-infrastructures.eu/gCubeApps/StockAssessment";
|
||||||
|
|
||||||
public static SortedSet<String> getContexts() throws Exception {
|
public static SortedSet<String> getContexts() throws Exception {
|
||||||
SortedSet<String> contexts = new TreeSet<>();
|
SortedSet<String> contexts = new TreeSet<>();
|
||||||
|
@ -69,7 +73,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
public void getDimensions() {
|
public void getDimensions() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Utils.setContext(ROOT);
|
ContextTest.setContextByName(ROOT);
|
||||||
|
|
||||||
AccountingDao dao = AccountingDao.get();
|
AccountingDao dao = AccountingDao.get();
|
||||||
|
|
||||||
|
@ -89,7 +93,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
public void launch() {
|
public void launch() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Utils.setContext(ROOT);
|
ContextTest.setContextByName(ROOT);
|
||||||
|
|
||||||
DataHarvestPluginDeclaration dataHarvestPluginDeclaration = new DataHarvestPluginDeclaration();
|
DataHarvestPluginDeclaration dataHarvestPluginDeclaration = new DataHarvestPluginDeclaration();
|
||||||
|
|
||||||
|
@ -121,12 +125,11 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
public void launchPluginOnSmartExecutor() {
|
public void launchPluginOnSmartExecutor() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Utils.setContext(ROOT);
|
ContextTest.setContextByName(ROOT);
|
||||||
|
|
||||||
SmartExecutor smartExecutor = SmartExecutorClientFactory.create(DataHarvestPluginDeclaration.NAME);
|
SmartExecutor smartExecutor = SmartExecutorClientFactory.create(DataHarvestPluginDeclaration.NAME);
|
||||||
Assert.assertNotNull(smartExecutor);
|
Assert.assertNotNull(smartExecutor);
|
||||||
|
@ -151,7 +154,8 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
CronExpression cronExpression = new CronExpression("0 0 10 3 1/1 ? *");
|
CronExpression cronExpression = new CronExpression("0 0 10 3 1/1 ? *");
|
||||||
Scheduling scheduling = new Scheduling(cronExpression);
|
Scheduling scheduling = new Scheduling(cronExpression);
|
||||||
scheduling.setGlobal(false);
|
scheduling.setGlobal(false);
|
||||||
LaunchParameter launchParameter = new LaunchParameter(DataHarvestPluginDeclaration.NAME, inputs, scheduling);
|
LaunchParameter launchParameter = new LaunchParameter(DataHarvestPluginDeclaration.NAME, inputs,
|
||||||
|
scheduling);
|
||||||
smartExecutor.launch(launchParameter);
|
smartExecutor.launch(launchParameter);
|
||||||
|
|
||||||
logger.info("End.");
|
logger.info("End.");
|
||||||
|
@ -165,7 +169,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
public void launchOldData() {
|
public void launchOldData() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Utils.setContext(ROOT);
|
ContextTest.setContextByName(ROOT);
|
||||||
|
|
||||||
DataHarvestPluginDeclaration dataHarvestPluginDeclaration = new DataHarvestPluginDeclaration();
|
DataHarvestPluginDeclaration dataHarvestPluginDeclaration = new DataHarvestPluginDeclaration();
|
||||||
|
|
||||||
|
@ -204,7 +208,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
public void launchOldDataVREAccessesHarvester() {
|
public void launchOldDataVREAccessesHarvester() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Utils.setContext(ROOT);
|
ContextTest.setContextByName(ROOT);
|
||||||
// AccountingDao dao = AccountingDao.get();
|
// AccountingDao dao = AccountingDao.get();
|
||||||
|
|
||||||
DataHarvestPluginDeclaration dataHarvestPluginDeclaration = new DataHarvestPluginDeclaration();
|
DataHarvestPluginDeclaration dataHarvestPluginDeclaration = new DataHarvestPluginDeclaration();
|
||||||
|
@ -235,7 +239,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
|
|
||||||
for(String context : contexts) {
|
for(String context : contexts) {
|
||||||
// Setting the token for the context
|
// Setting the token for the context
|
||||||
Utils.setContext(contextAuthorization.getTokenForContext(context));
|
ContextTest.setContext(contextAuthorization.getTokenForContext(context));
|
||||||
|
|
||||||
ScopeBean scopeBean = new ScopeBean(context);
|
ScopeBean scopeBean = new ScopeBean(context);
|
||||||
|
|
||||||
|
@ -252,12 +256,12 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setting back token for the context
|
// Setting back token for the context
|
||||||
Utils.setContext(contextAuthorization.getTokenForContext(parent.toString()));
|
ContextTest.setContext(contextAuthorization.getTokenForContext(parent.toString()));
|
||||||
|
|
||||||
vreAccessesHarvester = new VREAccessesHarvester(start, end);
|
vreAccessesHarvester = new VREAccessesHarvester(start, end);
|
||||||
|
|
||||||
// Setting back token for the context
|
// Setting back token for the context
|
||||||
Utils.setContext(contextAuthorization.getTokenForContext(context));
|
ContextTest.setContext(contextAuthorization.getTokenForContext(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -280,7 +284,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
|
|
||||||
logger.debug("Harvest Measures from {} to {} are {}", DateUtils.format(start), DateUtils.format(end),
|
logger.debug("Harvest Measures from {} to {} are {}", DateUtils.format(start), DateUtils.format(end),
|
||||||
accountingRecords);
|
accountingRecords);
|
||||||
Utils.setContext(ROOT);
|
ContextTest.setContextByName(ROOT);
|
||||||
|
|
||||||
// dao.insertRecords(accountingRecords.toArray(new AccountingRecord[1]));
|
// dao.insertRecords(accountingRecords.toArray(new AccountingRecord[1]));
|
||||||
|
|
||||||
|
@ -290,7 +294,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils.setContext(ROOT);
|
ContextTest.setContextByName(ROOT);
|
||||||
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
logger.error("", e);
|
logger.error("", e);
|
||||||
|
@ -302,7 +306,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
public void testScopeBean() throws Exception {
|
public void testScopeBean() throws Exception {
|
||||||
Utils.setContext(ROOT);
|
ContextTest.setContextByName(ROOT);
|
||||||
SortedSet<String> contexts = getContexts();
|
SortedSet<String> contexts = getContexts();
|
||||||
|
|
||||||
AggregationType aggregationType = AggregationType.MONTHLY;
|
AggregationType aggregationType = AggregationType.MONTHLY;
|
||||||
|
@ -346,11 +350,61 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testVREAccessesHarvester() throws Exception {
|
||||||
|
try {
|
||||||
|
AccountingDao dao = getAccountingDao();
|
||||||
|
|
||||||
|
List<Date> starts = new ArrayList<>();
|
||||||
|
starts.add(DateUtils.getStartCalendar(2018, Calendar.SEPTEMBER, 1).getTime());
|
||||||
|
starts.add(DateUtils.getStartCalendar(2018, Calendar.OCTOBER, 1).getTime());
|
||||||
|
starts.add(DateUtils.getStartCalendar(2018, Calendar.NOVEMBER, 1).getTime());
|
||||||
|
starts.add(DateUtils.getStartCalendar(2018, Calendar.DECEMBER, 1).getTime());
|
||||||
|
starts.add(DateUtils.getStartCalendar(2019, Calendar.JANUARY, 1).getTime());
|
||||||
|
starts.add(DateUtils.getStartCalendar(2019, Calendar.FEBRUARY, 1).getTime());
|
||||||
|
starts.add(DateUtils.getStartCalendar(2019, Calendar.MARCH, 1).getTime());
|
||||||
|
|
||||||
|
AggregationType measureType = AggregationType.MONTHLY;
|
||||||
|
|
||||||
|
String[] contextFullNames = new String[] {"/d4science.research-infrastructures.eu/FARM/GRSF",
|
||||||
|
"/d4science.research-infrastructures.eu/FARM/GRSF_Admin"};
|
||||||
|
|
||||||
|
List<AccountingRecord> accountingRecords = new ArrayList<>();
|
||||||
|
|
||||||
|
for(Date start : starts) {
|
||||||
|
Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1);
|
||||||
|
|
||||||
|
ContextTest.setContextByName(ROOT);
|
||||||
|
VREAccessesHarvester vreAccessesHarvester = new VREAccessesHarvester(start, end);
|
||||||
|
|
||||||
|
for(String contextFullname : contextFullNames) {
|
||||||
|
|
||||||
|
setContextByNameAndScopeDescriptor(contextFullname);
|
||||||
|
|
||||||
|
List<AccountingRecord> harvested = vreAccessesHarvester.getAccountingRecords();
|
||||||
|
accountingRecords.addAll(harvested);
|
||||||
|
|
||||||
|
logger.debug("{} - {}", contextFullname, accountingRecords);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug("{}", accountingRecords);
|
||||||
|
|
||||||
|
ContextTest.setContextByName(ROOT);
|
||||||
|
// dao.insertRecords(accountingRecords.toArray(new AccountingRecord[1]));
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
logger.error("", e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
public void testVREAccessesHarvester() {
|
public void testVREAccessesHarvesterAll() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Utils.setContext(ROOT);
|
ContextTest.setContextByName(ROOT);
|
||||||
|
|
||||||
AggregationType measureType = AggregationType.MONTHLY;
|
AggregationType measureType = AggregationType.MONTHLY;
|
||||||
|
|
||||||
|
@ -372,7 +426,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
|
|
||||||
for(String context : contexts) {
|
for(String context : contexts) {
|
||||||
// Setting the token for the context
|
// Setting the token for the context
|
||||||
Utils.setContext(contextAuthorization.getTokenForContext(context));
|
ContextTest.setContext(contextAuthorization.getTokenForContext(context));
|
||||||
|
|
||||||
ScopeBean scopeBean = new ScopeBean(context);
|
ScopeBean scopeBean = new ScopeBean(context);
|
||||||
|
|
||||||
|
@ -389,12 +443,12 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setting back token for the context
|
// Setting back token for the context
|
||||||
Utils.setContext(contextAuthorization.getTokenForContext(parent.toString()));
|
ContextTest.setContext(contextAuthorization.getTokenForContext(parent.toString()));
|
||||||
|
|
||||||
vreAccessesHarvester = new VREAccessesHarvester(start, end);
|
vreAccessesHarvester = new VREAccessesHarvester(start, end);
|
||||||
|
|
||||||
// Setting back token for the context
|
// Setting back token for the context
|
||||||
Utils.setContext(contextAuthorization.getTokenForContext(context));
|
ContextTest.setContext(contextAuthorization.getTokenForContext(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -425,7 +479,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
public void testSocialInteraction() {
|
public void testSocialInteraction() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Utils.setContext(ROOT);
|
ContextTest.setContextByName(ROOT);
|
||||||
// AccountingDao dao = AccountingDao.get();
|
// AccountingDao dao = AccountingDao.get();
|
||||||
|
|
||||||
DataHarvestPluginDeclaration dataHarvestPluginDeclaration = new DataHarvestPluginDeclaration();
|
DataHarvestPluginDeclaration dataHarvestPluginDeclaration = new DataHarvestPluginDeclaration();
|
||||||
|
@ -457,7 +511,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
|
|
||||||
for(String context : contexts) {
|
for(String context : contexts) {
|
||||||
// Setting the token for the context
|
// Setting the token for the context
|
||||||
Utils.setContext(contextAuthorization.getTokenForContext(context));
|
ContextTest.setContext(contextAuthorization.getTokenForContext(context));
|
||||||
try {
|
try {
|
||||||
// Collecting info on social (posts, replies and likes)
|
// Collecting info on social (posts, replies and likes)
|
||||||
logger.info("Going to harvest Social Interactions for {}", context);
|
logger.info("Going to harvest Social Interactions for {}", context);
|
||||||
|
@ -471,7 +525,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
|
|
||||||
logger.debug("Harvest Measures from {} to {} are {}", DateUtils.format(start), DateUtils.format(end),
|
logger.debug("Harvest Measures from {} to {} are {}", DateUtils.format(start), DateUtils.format(end),
|
||||||
accountingRecords);
|
accountingRecords);
|
||||||
Utils.setContext(ROOT);
|
ContextTest.setContextByName(ROOT);
|
||||||
// dao.insertRecords(accountingRecords.toArray(new AccountingRecord[1]));
|
// dao.insertRecords(accountingRecords.toArray(new AccountingRecord[1]));
|
||||||
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
|
@ -486,7 +540,11 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
public void testMethodInvocation() {
|
public void testMethodInvocation() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Utils.setContext(StockAssessment);
|
ContextTest.setContextByName(ROOT);
|
||||||
|
ContextAuthorization contextAuthorization = new ContextAuthorization();
|
||||||
|
String stockAssessmentToken = contextAuthorization.generateTokenForContext(STOCK_ASSESMENT_VRE, null);
|
||||||
|
|
||||||
|
ContextTest.setContext(stockAssessmentToken);
|
||||||
|
|
||||||
AggregationType measureType = AggregationType.MONTHLY;
|
AggregationType measureType = AggregationType.MONTHLY;
|
||||||
|
|
||||||
|
@ -503,31 +561,85 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Test
|
protected AccountingDao getAccountingDao() throws ObjectNotFound, Exception {
|
||||||
public void testTagMeMethodInvocation() {
|
ContextTest.setContextByName(ROOT);
|
||||||
try {
|
AccountingDao dao = AccountingDao.get();
|
||||||
|
|
||||||
Utils.setContext(TAGME);
|
Set<ScopeDescriptor> scopeDescriptorSet = dao.getContexts();
|
||||||
|
Map<String,ScopeDescriptor> scopeDescriptorMap = new HashMap<>();
|
||||||
|
for(ScopeDescriptor scopeDescriptor : scopeDescriptorSet) {
|
||||||
|
scopeDescriptorMap.put(scopeDescriptor.getId(), scopeDescriptor);
|
||||||
|
}
|
||||||
|
AccountingDataHarvesterPlugin.scopeDescriptors.set(scopeDescriptorMap);
|
||||||
|
|
||||||
|
Set<Dimension> dimensionSet = dao.getDimensions();
|
||||||
|
Map<String,Dimension> dimensionMap = new HashMap<>();
|
||||||
|
for(Dimension dimension : dimensionSet) {
|
||||||
|
dimensionMap.put(dimension.getId(), dimension);
|
||||||
|
}
|
||||||
|
|
||||||
|
AccountingDataHarvesterPlugin.dimensions.set(dimensionMap);
|
||||||
|
|
||||||
|
return dao;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setContextByNameAndScopeDescriptor(String contextFullName) throws ObjectNotFound, Exception {
|
||||||
|
ContextAuthorization contextAuthorization = new ContextAuthorization();
|
||||||
|
String tagMeToken = contextAuthorization.getTokenForContext(contextFullName);
|
||||||
|
|
||||||
|
ContextTest.setContext(tagMeToken);
|
||||||
|
|
||||||
|
ScopeBean scopeBean = new ScopeBean(contextFullName);
|
||||||
|
ScopeDescriptor actualScopeDescriptor = AccountingDataHarvesterPlugin.scopeDescriptors.get()
|
||||||
|
.get(contextFullName);
|
||||||
|
if(actualScopeDescriptor == null) {
|
||||||
|
actualScopeDescriptor = new ScopeDescriptor(scopeBean.name(), contextFullName);
|
||||||
|
}
|
||||||
|
|
||||||
|
AccountingDataHarvesterPlugin.scopeDescriptor.set(actualScopeDescriptor);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTagMeMethodInvocation() throws Exception {
|
||||||
|
try {
|
||||||
|
AccountingDao dao = getAccountingDao();
|
||||||
|
setContextByNameAndScopeDescriptor(TAGME_VRE);
|
||||||
|
|
||||||
|
List<AccountingRecord> accountingRecords = new ArrayList<>();
|
||||||
|
|
||||||
AggregationType measureType = AggregationType.MONTHLY;
|
AggregationType measureType = AggregationType.MONTHLY;
|
||||||
|
|
||||||
Date start = DateUtils.getPreviousPeriod(measureType).getTime();
|
List<Date> starts = new ArrayList<>();
|
||||||
|
starts.add(DateUtils.getStartCalendar(2018, Calendar.NOVEMBER, 1).getTime());
|
||||||
|
starts.add(DateUtils.getStartCalendar(2018, Calendar.DECEMBER, 1).getTime());
|
||||||
|
starts.add(DateUtils.getStartCalendar(2019, Calendar.JANUARY, 1).getTime());
|
||||||
|
starts.add(DateUtils.getStartCalendar(2019, Calendar.FEBRUARY, 1).getTime());
|
||||||
|
starts.add(DateUtils.getStartCalendar(2019, Calendar.MARCH, 1).getTime());
|
||||||
|
|
||||||
|
for(Date start : starts) {
|
||||||
|
|
||||||
Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1);
|
Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1);
|
||||||
|
|
||||||
TagMeMethodInvocationHarvester methodInvocationHarvester = new TagMeMethodInvocationHarvester(start, end);
|
TagMeMethodInvocationHarvester methodInvocationHarvester = new TagMeMethodInvocationHarvester(start,
|
||||||
List<AccountingRecord> accountingRecords = methodInvocationHarvester.getAccountingRecords();
|
end);
|
||||||
|
accountingRecords.addAll(methodInvocationHarvester.getAccountingRecords());
|
||||||
|
|
||||||
logger.debug("{}", accountingRecords);
|
logger.debug("{}", accountingRecords);
|
||||||
|
}
|
||||||
|
|
||||||
|
ContextTest.setContextByName(ROOT);
|
||||||
|
//dao.insertRecords(accountingRecords.toArray(new AccountingRecord[1]));
|
||||||
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
logger.error("", e);
|
logger.error("", e);
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
public void testGetVREUsersForSpecificVRE() {
|
public void testGetVREUsersForSpecificVRE() {
|
||||||
try {
|
try {
|
||||||
Utils.setContext(ROOT);
|
ContextTest.setContextByName(ROOT);
|
||||||
|
|
||||||
DataHarvestPluginDeclaration dataHarvestPluginDeclaration = new DataHarvestPluginDeclaration();
|
DataHarvestPluginDeclaration dataHarvestPluginDeclaration = new DataHarvestPluginDeclaration();
|
||||||
AccountingDataHarvesterPlugin accountingDataHarvesterPlugin = new AccountingDataHarvesterPlugin(
|
AccountingDataHarvesterPlugin accountingDataHarvesterPlugin = new AccountingDataHarvesterPlugin(
|
||||||
|
@ -538,7 +650,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
// AccountingDao dao = AccountingDao.get();
|
// AccountingDao dao = AccountingDao.get();
|
||||||
|
|
||||||
ContextAuthorization contextAuthorization = new ContextAuthorization();
|
ContextAuthorization contextAuthorization = new ContextAuthorization();
|
||||||
Utils.setContext(contextAuthorization
|
ContextTest.setContext(contextAuthorization
|
||||||
.getTokenForContext("/d4science.research-infrastructures.eu/SoBigData/SportsDataScience"));
|
.getTokenForContext("/d4science.research-infrastructures.eu/SoBigData/SportsDataScience"));
|
||||||
|
|
||||||
AggregationType measureType = AggregationType.MONTHLY;
|
AggregationType measureType = AggregationType.MONTHLY;
|
||||||
|
@ -551,7 +663,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
|
|
||||||
logger.info("Harvested Data from {} to {} : {}", DateUtils.format(start), DateUtils.format(end), harvested);
|
logger.info("Harvested Data from {} to {} : {}", DateUtils.format(start), DateUtils.format(end), harvested);
|
||||||
|
|
||||||
org.gcube.dataharvest.utils.Utils.setContext(ROOT);
|
ContextTest.setContextByName(ROOT);
|
||||||
// dao.insertRecords(accountingRecords.toArray(new AccountingRecord[1]));
|
// dao.insertRecords(accountingRecords.toArray(new AccountingRecord[1]));
|
||||||
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
|
@ -563,7 +675,8 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
// @Test
|
// @Test
|
||||||
public void testFilteringGenericResource() {
|
public void testFilteringGenericResource() {
|
||||||
try {
|
try {
|
||||||
Utils.setContext(RESOURCE_CATALOGUE);
|
ContextTest.setContextByName(ROOT);
|
||||||
|
//Utils.setContext(RESOURCE_CATALOGUE);
|
||||||
|
|
||||||
AggregationType measureType = AggregationType.MONTHLY;
|
AggregationType measureType = AggregationType.MONTHLY;
|
||||||
|
|
||||||
|
@ -577,8 +690,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
|
|
||||||
ResourceCatalogueHarvester resourceCatalogueHarvester = new ResourceCatalogueHarvester(start, end,
|
ResourceCatalogueHarvester resourceCatalogueHarvester = new ResourceCatalogueHarvester(start, end,
|
||||||
contexts);
|
contexts);
|
||||||
SortedSet<String> validContexts = resourceCatalogueHarvester.getValidContexts(contexts,
|
SortedSet<String> validContexts = resourceCatalogueHarvester.getValidContexts(contexts, SO_BIG_VO + "/");
|
||||||
SO_BIG_DATA_CONTEXT + "/");
|
|
||||||
logger.info("Valid Contexts {}", validContexts);
|
logger.info("Valid Contexts {}", validContexts);
|
||||||
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
|
@ -591,7 +703,8 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
public void testResourceCatalogueHarvester() {
|
public void testResourceCatalogueHarvester() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Utils.setContext(RESOURCE_CATALOGUE);
|
//Utils.setContext(RESOURCE_CATALOGUE);
|
||||||
|
ContextTest.setContextByName(ROOT);
|
||||||
|
|
||||||
AggregationType measureType = AggregationType.MONTHLY;
|
AggregationType measureType = AggregationType.MONTHLY;
|
||||||
|
|
||||||
|
@ -621,7 +734,8 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
public void testDataMethodDownloadHarvester() {
|
public void testDataMethodDownloadHarvester() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Utils.setContext(RESOURCE_CATALOGUE);
|
//Utils.setContext(RESOURCE_CATALOGUE);
|
||||||
|
ContextTest.setContextByName(ROOT);
|
||||||
|
|
||||||
AggregationType measureType = AggregationType.MONTHLY;
|
AggregationType measureType = AggregationType.MONTHLY;
|
||||||
|
|
||||||
|
@ -647,14 +761,13 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static final String E_LEARNING_AREA_VRE = "/d4science.research-infrastructures.eu/SoBigData/E-Learning_Area";
|
public static final String E_LEARNING_AREA_VRE = "/d4science.research-infrastructures.eu/SoBigData/E-Learning_Area";
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
public void addMissingVREAccesses() {
|
public void addMissingVREAccesses() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Utils.setContext(ROOT);
|
ContextTest.setContextByName(ROOT);
|
||||||
|
|
||||||
DataHarvestPluginDeclaration dataHarvestPluginDeclaration = new DataHarvestPluginDeclaration();
|
DataHarvestPluginDeclaration dataHarvestPluginDeclaration = new DataHarvestPluginDeclaration();
|
||||||
AccountingDataHarvesterPlugin adhp = new AccountingDataHarvesterPlugin(dataHarvestPluginDeclaration);
|
AccountingDataHarvesterPlugin adhp = new AccountingDataHarvesterPlugin(dataHarvestPluginDeclaration);
|
||||||
|
@ -673,7 +786,6 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
}
|
}
|
||||||
AccountingDataHarvesterPlugin.scopeDescriptors.set(scopeDescriptorMap);
|
AccountingDataHarvesterPlugin.scopeDescriptors.set(scopeDescriptorMap);
|
||||||
|
|
||||||
|
|
||||||
Set<Dimension> dimensionSet = dao.getDimensions();
|
Set<Dimension> dimensionSet = dao.getDimensions();
|
||||||
Map<String,Dimension> dimensionMap = new HashMap<>();
|
Map<String,Dimension> dimensionMap = new HashMap<>();
|
||||||
for(Dimension dimension : dimensionSet) {
|
for(Dimension dimension : dimensionSet) {
|
||||||
|
@ -688,8 +800,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
String context = E_LEARNING_AREA_VRE;
|
String context = E_LEARNING_AREA_VRE;
|
||||||
|
|
||||||
// Setting the token for the context
|
// Setting the token for the context
|
||||||
Utils.setContext(contextAuthorization.getTokenForContext(context));
|
ContextTest.setContext(contextAuthorization.getTokenForContext(context));
|
||||||
|
|
||||||
|
|
||||||
ScopeBean scopeBean = new ScopeBean(context);
|
ScopeBean scopeBean = new ScopeBean(context);
|
||||||
ScopeDescriptor scopeDescriptor = new ScopeDescriptor(scopeBean.name(), context);
|
ScopeDescriptor scopeDescriptor = new ScopeDescriptor(scopeBean.name(), context);
|
||||||
|
@ -699,7 +810,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
Calendar calendar = DateUtils.getStartCalendar(2018, Calendar.JULY, 1);
|
Calendar calendar = DateUtils.getStartCalendar(2018, Calendar.JULY, 1);
|
||||||
calendar.set(Calendar.DAY_OF_MONTH, 15);
|
calendar.set(Calendar.DAY_OF_MONTH, 15);
|
||||||
|
|
||||||
Map<Integer, Integer> monthValues = new HashMap<>();
|
Map<Integer,Integer> monthValues = new HashMap<>();
|
||||||
monthValues.put(Calendar.JULY, 54);
|
monthValues.put(Calendar.JULY, 54);
|
||||||
monthValues.put(Calendar.AUGUST, 23);
|
monthValues.put(Calendar.AUGUST, 23);
|
||||||
monthValues.put(Calendar.SEPTEMBER, 127);
|
monthValues.put(Calendar.SEPTEMBER, 127);
|
||||||
|
@ -709,7 +820,8 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
calendar.set(Calendar.MONTH, month);
|
calendar.set(Calendar.MONTH, month);
|
||||||
Instant instant = calendar.toInstant();
|
Instant instant = calendar.toInstant();
|
||||||
|
|
||||||
AccountingRecord ar = new AccountingRecord(scopeDescriptor, instant, dimension, (long) monthValues.get(month));
|
AccountingRecord ar = new AccountingRecord(scopeDescriptor, instant, dimension,
|
||||||
|
(long) monthValues.get(month));
|
||||||
logger.debug("{} : {}", ar.getDimension().getId(), ar.getMeasure());
|
logger.debug("{} : {}", ar.getDimension().getId(), ar.getMeasure());
|
||||||
accountingRecords.add(ar);
|
accountingRecords.add(ar);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,13 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.gcube.common.authorization.client.Constants;
|
||||||
|
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
||||||
|
import org.gcube.common.authorization.library.AuthorizationEntry;
|
||||||
|
import org.gcube.common.authorization.library.provider.AuthorizationProvider;
|
||||||
|
import org.gcube.common.authorization.library.provider.ClientInfo;
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
|
import org.gcube.common.authorization.library.utils.Caller;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
@ -16,43 +22,19 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public class ContextTest {
|
public class ContextTest {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ContextTest.class);
|
private static final Logger logger = LoggerFactory.getLogger(ContextTest.class);
|
||||||
|
|
||||||
|
protected static Properties properties;
|
||||||
protected static final String PROPERTIES_FILENAME = "token.properties";
|
protected static final String PROPERTIES_FILENAME = "token.properties";
|
||||||
|
|
||||||
private static final String GCUBE_DEVNEXT_VARNAME = "GCUBE_DEVNEXT";
|
public static final String DEFAULT_TEST_SCOPE_NAME;
|
||||||
public static final String GCUBE_DEVNEXT;
|
|
||||||
|
|
||||||
private static final String GCUBE_DEVNEXT_NEXTNEXT_VARNAME = "GCUBE_DEVNEXT_NEXTNEXT";
|
|
||||||
public static final String GCUBE_DEVNEXT_NEXTNEXT;
|
|
||||||
|
|
||||||
public static final String GCUBE_VARNAME = "GCUBE";
|
|
||||||
public static final String GCUBE;
|
|
||||||
|
|
||||||
public static final String DEFAULT_TEST_SCOPE;
|
|
||||||
|
|
||||||
public static final String ROOT_VARNAME = "ROOT_ERIC";
|
|
||||||
public static final String ROOT;
|
|
||||||
|
|
||||||
public static final String TAGME_VARNAME = "TAGME_ERIC";
|
|
||||||
public static final String TAGME;
|
|
||||||
|
|
||||||
public static final String StockAssessment_VARNAME = "StockAssessment";
|
|
||||||
public static final String StockAssessment;
|
|
||||||
|
|
||||||
public static final String RESOURCE_CATALOGUE_VARNAME = "RESOURCE_CATALOGUE";
|
|
||||||
public static final String RESOURCE_CATALOGUE;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
properties = new Properties();
|
||||||
logger.trace("Retrieving Tokens from {}", PROPERTIES_FILENAME);
|
|
||||||
|
|
||||||
Properties properties = new Properties();
|
|
||||||
InputStream input = ContextTest.class.getClassLoader().getResourceAsStream(PROPERTIES_FILENAME);
|
InputStream input = ContextTest.class.getClassLoader().getResourceAsStream(PROPERTIES_FILENAME);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -62,25 +44,36 @@ public class ContextTest {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
GCUBE = properties.getProperty(GCUBE_VARNAME);
|
//DEFAULT_TEST_SCOPE_NAME = "/pred4s/preprod/preVRE";
|
||||||
|
DEFAULT_TEST_SCOPE_NAME = "/gcube/devNext/NextNext";
|
||||||
|
}
|
||||||
|
|
||||||
GCUBE_DEVNEXT = properties.getProperty(GCUBE_DEVNEXT_VARNAME);
|
public static String getCurrentScope(String token) throws ObjectNotFound, Exception {
|
||||||
GCUBE_DEVNEXT_NEXTNEXT = properties.getProperty(GCUBE_DEVNEXT_NEXTNEXT_VARNAME);
|
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token);
|
||||||
|
String context = authorizationEntry.getContext();
|
||||||
|
logger.info("Context of token {} is {}", token, context);
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
ROOT = properties.getProperty(ROOT_VARNAME);
|
public static void setContextByName(String fullContextName) throws ObjectNotFound, Exception {
|
||||||
|
String token = ContextTest.properties.getProperty(fullContextName);
|
||||||
|
setContext(token);
|
||||||
|
}
|
||||||
|
|
||||||
TAGME = properties.getProperty(TAGME_VARNAME);
|
public static void setContext(String token) throws ObjectNotFound, Exception {
|
||||||
|
SecurityTokenProvider.instance.set(token);
|
||||||
RESOURCE_CATALOGUE = properties.getProperty(RESOURCE_CATALOGUE_VARNAME);
|
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token);
|
||||||
|
ClientInfo clientInfo = authorizationEntry.getClientInfo();
|
||||||
StockAssessment = properties.getProperty(StockAssessment_VARNAME);
|
logger.debug("User : {} - Type : {}", clientInfo.getId(), clientInfo.getType().name());
|
||||||
|
String qualifier = authorizationEntry.getQualifier();
|
||||||
DEFAULT_TEST_SCOPE = GCUBE;
|
Caller caller = new Caller(clientInfo, qualifier);
|
||||||
|
AuthorizationProvider.instance.set(caller);
|
||||||
|
ScopeProvider.instance.set(getCurrentScope(token));
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeClass() throws Exception {
|
public static void beforeClass() throws Exception {
|
||||||
Utils.setContext(DEFAULT_TEST_SCOPE);
|
setContextByName(DEFAULT_TEST_SCOPE_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
|
|
Loading…
Reference in New Issue