83 lines
2.1 KiB
Java
83 lines
2.1 KiB
Java
package org.gcube.portlets.user.accountingdashboard;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import org.gcube.portlets.user.accountingdashboard.server.accounting.AccountingService;
|
|
import org.gcube.portlets.user.accountingdashboard.server.accounting.AccountingServiceType;
|
|
import org.gcube.portlets.user.accountingdashboard.shared.Constants;
|
|
import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData;
|
|
import org.junit.Test;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import junit.framework.TestCase;
|
|
|
|
/**
|
|
*
|
|
* @author Giancarlo Panichi
|
|
*
|
|
*
|
|
*/
|
|
public class AccountingServiceTest extends TestCase {
|
|
private static Logger logger = LoggerFactory.getLogger(AccountingServiceTest.class);
|
|
|
|
@Test
|
|
public void testCMESService() {
|
|
if (Constants.TEST_ENABLE) {
|
|
|
|
try {
|
|
AuthTest.setToken();
|
|
AccountingService accountingService = new AccountingService(AccountingServiceType.CurrentScope);
|
|
accountingService.getTree();
|
|
|
|
assertTrue("Success", true);
|
|
} catch (Throwable e) {
|
|
logger.error(e.getLocalizedMessage(), e);
|
|
fail("Error:" + e.getLocalizedMessage());
|
|
|
|
}
|
|
|
|
} else {
|
|
assertTrue("Success", true);
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void testData() {
|
|
if (Constants.TEST_ENABLE) {
|
|
|
|
try {
|
|
|
|
ScopeData children1 = new ScopeData("1", "children1", null);
|
|
ScopeData children3 = new ScopeData("3", "children3", null);
|
|
ScopeData children4 = new ScopeData("4", "children4", null);
|
|
|
|
ArrayList<ScopeData> children2List = new ArrayList<>();
|
|
children2List.add(children3);
|
|
children2List.add(children4);
|
|
ScopeData children2 = new ScopeData("2", "children2", children2List);
|
|
|
|
ArrayList<ScopeData> rootList = new ArrayList<>();
|
|
rootList.add(children1);
|
|
rootList.add(children2);
|
|
ScopeData root = new ScopeData("0", "root", rootList);
|
|
|
|
ArrayList<ScopeData> scopeDataList = new ArrayList<>();
|
|
scopeDataList.add(root);
|
|
logger.debug("Data example: "+scopeDataList);
|
|
|
|
assertTrue("Success", true);
|
|
|
|
|
|
} catch (Throwable e) {
|
|
logger.error(e.getLocalizedMessage(), e);
|
|
fail("Error:" + e.getLocalizedMessage());
|
|
|
|
}
|
|
|
|
} else {
|
|
assertTrue("Success", true);
|
|
}
|
|
}
|
|
|
|
} |