fixed tests

pull/1/head
Luca Frosini 3 years ago
parent 1b500a2f3d
commit 695bf798f9

@ -56,18 +56,21 @@ public class AccountingDataHarvesterJupyterTest extends ContextTest {
return dao;
}
@Ignore
//@Ignore
@Test
public void testJupyterAccessesHarvester() throws Exception {
try {
// ContextTest.setContextByName(ROOT);
// AccountingDao dao = getAccountingDao();
ContextTest.setContextByName(ROOT);
AccountingDao dao = getAccountingDao();
List<Date> starts = new ArrayList<>();
starts.add(DateUtils.getStartCalendar(2021, Calendar.JANUARY, 1).getTime());
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());
AggregationType measureType = AggregationType.MONTHLY;
@ -96,7 +99,7 @@ public class AccountingDataHarvesterJupyterTest extends ContextTest {
logger.debug("Going to insert {}", accountingRecords);
ContextTest.setContextByName(ROOT);
// dao.insertRecords(accountingRecords.toArray(new AccountingRecord[1]));
dao.insertRecords(accountingRecords.toArray(new AccountingRecord[1]));
} catch (Throwable e) {
logger.error(e.getLocalizedMessage(), e);

@ -91,8 +91,8 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
logger.error("", e);
}
}
@Ignore
//@Ignore
@Test
public void launch() {
try {
@ -109,17 +109,12 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
inputs.put(AccountingDashboardHarvesterPlugin.GET_VRE_USERS_INPUT_PARAMETER, true);
inputs.put(AccountingDashboardHarvesterPlugin.RERUN_INPUT_PARAMETER, true);
inputs.put(AccountingDashboardHarvesterPlugin.DRY_RUN_INPUT_PARAMETER, true);
inputs.put(AccountingDashboardHarvesterPlugin.PARTIAL_HARVESTING, false);
inputs.put(AccountingDashboardHarvesterPlugin.PARTIAL_HARVESTING, true);
/*
* Calendar from = DateUtils.getStartCalendar(2020, Calendar.MAY,
* 1); String fromDate =
* DateUtils.LAUNCH_DATE_FORMAT.format(from.getTime());
* logger.trace("{} is {}",
* AccountingDashboardHarvesterPlugin.START_DATE_INPUT_PARAMETER,
* fromDate); inputs.put(AccountingDashboardHarvesterPlugin.
* START_DATE_INPUT_PARAMETER, fromDate);
*/
Calendar from = DateUtils.getStartCalendar(2021, Calendar.JANUARY, 1);
String fromDate = DateUtils.LAUNCH_DATE_FORMAT.format(from.getTime());
logger.trace("{} is {}", AccountingDashboardHarvesterPlugin.START_DATE_INPUT_PARAMETER, fromDate);
inputs.put(AccountingDashboardHarvesterPlugin.START_DATE_INPUT_PARAMETER, fromDate);
accountingDataHarvesterPlugin.launch(inputs);
@ -153,13 +148,12 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
inputs.put(AccountingDashboardHarvesterPlugin.PARTIAL_HARVESTING, false);
/*
* Calendar from = DateUtils.getStartCalendar(2016,
* Calendar.SEPTEMBER, 1); String fromDate =
* DateUtils.LAUNCH_DATE_FORMAT.format(from.getTime());
* Calendar from = DateUtils.getStartCalendar(2016, Calendar.SEPTEMBER, 1);
* String fromDate = DateUtils.LAUNCH_DATE_FORMAT.format(from.getTime());
* logger.trace("{} is {}",
* AccountingDataHarvesterPlugin.START_DATE_INPUT_PARAMETER,
* fromDate); inputs.put(AccountingDataHarvesterPlugin.
* START_DATE_INPUT_PARAMETER, fromDate);
* AccountingDataHarvesterPlugin.START_DATE_INPUT_PARAMETER, fromDate);
* inputs.put(AccountingDataHarvesterPlugin. START_DATE_INPUT_PARAMETER,
* fromDate);
*/
// 3rd of the month for MONTHLY Harvesting at 10:00
@ -184,8 +178,8 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
}
}
@Ignore
//@Test
//@Ignore
@Test
public void launchOldData() {
try {
@ -587,7 +581,52 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
logger.error("", e);
}
}
@Test
public void testMethodInvocationOldData() {
try {
ContextTest.setContextByName(ROOT);
AccountingDao dao = getAccountingDao();
List<Date> starts = new ArrayList<>();
starts.add(DateUtils.getStartCalendar(2021, Calendar.APRIL, 1).getTime());
AggregationType measureType = AggregationType.MONTHLY;
ContextAuthorization contextAuthorization = new ContextAuthorization();
SortedSet<String> contexts = contextAuthorization.getContexts();
List<AccountingRecord> accountingRecords = new ArrayList<>();
for (Date start : starts) {
Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1, false);
MethodInvocationHarvester methodInvocationHarvester = new MethodInvocationHarvester(start, end);
for (String context : contexts) {
// Setting the token for the context
ContextTest.setContext(contextAuthorization.getTokenForContext(context));
List<AccountingRecord> harvested = methodInvocationHarvester.getAccountingRecords();
accountingRecords.addAll(harvested);
logger.debug("{} - {}", context, harvested);
}
}
logger.debug("Going to insert {}", accountingRecords);
ContextTest.setContextByName(ROOT);
dao.insertRecords(accountingRecords.toArray(new AccountingRecord[1]));
} catch (Exception e) {
logger.error("", e);
}
}
protected AccountingDao getAccountingDao() throws ObjectNotFound, Exception {
AccountingDao dao = AccountingDao.get();
@ -761,7 +800,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
logger.error("", e);
}
}
@Ignore
@Test
public void testCoreServicesHarvester() {
@ -797,7 +836,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
logger.error("", e);
}
}
@Ignore
@Test
public void testCatalogueHarvester() {
@ -812,9 +851,8 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
Date end = DateUtils.getStartCalendar(2020, Calendar.FEBRUARY, 1).getTime();
/*
* Date start = DateUtils.getPreviousPeriod(measureType,
* false).getTime(); Date end =
* DateUtils.getEndDateFromStartDate(measureType, start, 1, false);
* Date start = DateUtils.getPreviousPeriod(measureType, false).getTime(); Date
* end = DateUtils.getEndDateFromStartDate(measureType, start, 1, false);
*/
ScopeBean scopeBean = new ScopeBean(context);

Loading…
Cancel
Save