fixed test
This commit is contained in:
parent
8c7bf2c22b
commit
77311be1aa
|
@ -112,7 +112,7 @@ public class AccountingDashboardHarvesterPlugin extends Plugin {
|
|||
return scopeDescriptors.get().get(context);
|
||||
}
|
||||
|
||||
protected static final InheritableThreadLocal<Map<String, ScopeDescriptor>> scopeDescriptors = new InheritableThreadLocal<Map<String, ScopeDescriptor>>() {
|
||||
public static final InheritableThreadLocal<Map<String, ScopeDescriptor>> scopeDescriptors = new InheritableThreadLocal<Map<String, ScopeDescriptor>>() {
|
||||
|
||||
@Override
|
||||
protected Map<String, ScopeDescriptor> initialValue() {
|
||||
|
|
|
@ -8,18 +8,19 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
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.internal.Dimension;
|
||||
import org.gcube.accounting.accounting.summary.access.model.update.AccountingRecord;
|
||||
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
||||
import org.gcube.common.scope.impl.ScopeBean;
|
||||
import org.gcube.dataharvest.harvester.JupyterAccessesHarvester;
|
||||
import org.gcube.dataharvest.utils.AggregationType;
|
||||
import org.gcube.dataharvest.utils.ContextAuthorization;
|
||||
import org.gcube.dataharvest.utils.ContextTest;
|
||||
import org.gcube.dataharvest.utils.DateUtils;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -69,16 +70,30 @@ public class AccountingDataHarvesterJupyterTest extends ContextTest {
|
|||
starts.add(DateUtils.getStartCalendar(2021, Calendar.FEBRUARY, 1).getTime());
|
||||
starts.add(DateUtils.getStartCalendar(2021, Calendar.MARCH, 1).getTime());
|
||||
starts.add(DateUtils.getStartCalendar(2021, Calendar.APRIL, 1).getTime());
|
||||
//starts.add(DateUtils.getStartCalendar(2021, Calendar.MAY, 1).getTime());
|
||||
|
||||
starts.add(DateUtils.getStartCalendar(2021, Calendar.MAY, 1).getTime());
|
||||
|
||||
AggregationType measureType = AggregationType.MONTHLY;
|
||||
|
||||
ContextAuthorization contextAuthorization = new ContextAuthorization();
|
||||
|
||||
SortedSet<String> contexts = contextAuthorization.getContexts();
|
||||
/*
|
||||
SortedSet<String> contexts = new TreeSet<>();
|
||||
contexts.add("/d4science.research-infrastructures.eu/D4OS/Blue-CloudLab");
|
||||
contexts.add("/d4science.research-infrastructures.eu/D4OS/Zoo-Phytoplankton_EOV");
|
||||
contexts.add("/d4science.research-infrastructures.eu/D4OS/MarineEnvironmentalIndicators");
|
||||
*/
|
||||
|
||||
List<AccountingRecord> accountingRecords = new ArrayList<>();
|
||||
|
||||
Set<ScopeDescriptor> scopeDescriptorSet = dao.getContexts();
|
||||
Map<String, ScopeDescriptor> scopeDescriptorMap = new HashMap<>();
|
||||
for (ScopeDescriptor scopeDescriptor : scopeDescriptorSet) {
|
||||
scopeDescriptorMap.put(scopeDescriptor.getId(), scopeDescriptor);
|
||||
}
|
||||
AccountingDashboardHarvesterPlugin.scopeDescriptors.set(scopeDescriptorMap);
|
||||
|
||||
|
||||
for (Date start : starts) {
|
||||
Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1, false);
|
||||
|
||||
|
@ -88,6 +103,15 @@ public class AccountingDataHarvesterJupyterTest extends ContextTest {
|
|||
for(String context : contexts) {
|
||||
ContextTest.setContext(contextAuthorization.getTokenForContext(context));
|
||||
|
||||
ScopeBean scopeBean = new ScopeBean(context);
|
||||
|
||||
ScopeDescriptor actualScopeDescriptor = scopeDescriptorMap.get(context);
|
||||
if (actualScopeDescriptor == null) {
|
||||
actualScopeDescriptor = new ScopeDescriptor(scopeBean.name(), context);
|
||||
}
|
||||
|
||||
AccountingDashboardHarvesterPlugin.scopeDescriptor.set(actualScopeDescriptor);
|
||||
|
||||
List<AccountingRecord> harvested = jupyterAccessesHarvester.getAccountingRecords();
|
||||
accountingRecords.addAll(harvested);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue