Improved test

This commit is contained in:
Luca Frosini 2021-04-12 10:35:08 +02:00
parent 42527a425a
commit ac305c0a32
1 changed files with 15 additions and 7 deletions

View File

@ -4,10 +4,12 @@ import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.SortedSet;
import org.gcube.accounting.accounting.summary.access.model.update.AccountingRecord; import org.gcube.accounting.accounting.summary.access.model.update.AccountingRecord;
import org.gcube.dataharvest.harvester.JupyterAccessesHarvester; import org.gcube.dataharvest.harvester.JupyterAccessesHarvester;
import org.gcube.dataharvest.utils.AggregationType; import org.gcube.dataharvest.utils.AggregationType;
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.junit.Ignore; import org.junit.Ignore;
@ -24,7 +26,7 @@ public class AccountingDataHarvesterJupyterTest extends ContextTest {
private static Logger logger = LoggerFactory.getLogger(AccountingDataHarvesterJupyterTest.class); private static Logger logger = LoggerFactory.getLogger(AccountingDataHarvesterJupyterTest.class);
public static final String ROOT = "/d4science.research-infrastructures.eu"; public static final String ROOT = "/d4science.research-infrastructures.eu";
private static final String SCOPE = "/d4science.research-infrastructures.eu/D4OS/Blue-CloudLab"; // private static final String SCOPE = "/d4science.research-infrastructures.eu/D4OS/Blue-CloudLab";
@Ignore @Ignore
@Test @Test
@ -47,12 +49,18 @@ public class AccountingDataHarvesterJupyterTest extends ContextTest {
ContextTest.setContextByName(ROOT); ContextTest.setContextByName(ROOT);
JupyterAccessesHarvester jupyterAccessesHarvester = new JupyterAccessesHarvester(start, end); JupyterAccessesHarvester jupyterAccessesHarvester = new JupyterAccessesHarvester(start, end);
ContextTest.setContextByName(SCOPE);
ContextAuthorization contextAuthorization = new ContextAuthorization();
List<AccountingRecord> harvested = jupyterAccessesHarvester.getAccountingRecords(); SortedSet<String> contexts = contextAuthorization.getContexts();
accountingRecords.addAll(harvested);
for(String context : contexts) {
logger.debug("{} - {}", SCOPE, accountingRecords); ContextTest.setContext(contextAuthorization.getTokenForContext(context));
List<AccountingRecord> harvested = jupyterAccessesHarvester.getAccountingRecords();
accountingRecords.addAll(harvested);
logger.debug("{} - {}", context, accountingRecords);
}
} }