2017-09-05 17:13:50 +02:00
|
|
|
package org.gcube.accounting.aggregator.file;
|
|
|
|
|
|
|
|
import java.io.File;
|
2020-03-16 15:10:43 +01:00
|
|
|
import java.util.ArrayList;
|
2017-09-05 17:13:50 +02:00
|
|
|
import java.util.Calendar;
|
|
|
|
import java.util.Date;
|
2020-03-16 15:10:43 +01:00
|
|
|
import java.util.List;
|
2017-09-05 17:13:50 +02:00
|
|
|
|
2021-11-05 14:25:45 +01:00
|
|
|
import org.gcube.accounting.aggregator.ContextTest;
|
2017-09-05 17:13:50 +02:00
|
|
|
import org.gcube.accounting.aggregator.aggregation.AggregationType;
|
|
|
|
import org.gcube.accounting.aggregator.directory.WorkSpaceDirectoryStructure;
|
|
|
|
import org.gcube.accounting.aggregator.utility.Constant;
|
|
|
|
import org.gcube.accounting.aggregator.utility.Utility;
|
|
|
|
import org.gcube.accounting.aggregator.workspace.WorkSpaceManagement;
|
2020-03-11 18:52:39 +01:00
|
|
|
import org.gcube.common.storagehub.client.dsl.FolderContainer;
|
2017-09-05 17:13:50 +02:00
|
|
|
import org.junit.Test;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
2020-03-11 15:33:39 +01:00
|
|
|
public class WorkSpaceDirectoryStructureTest extends ContextTest {
|
2017-09-05 17:13:50 +02:00
|
|
|
|
|
|
|
public static Logger logger = LoggerFactory.getLogger(WorkSpaceDirectoryStructureTest.class);
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void test() throws Exception{
|
|
|
|
|
|
|
|
AggregationType aggregationType = AggregationType.YEARLY;
|
|
|
|
Date date = Utility.getAggregationStartCalendar(2015, Calendar.JANUARY, 1).getTime();
|
|
|
|
|
|
|
|
WorkSpaceDirectoryStructure workSpaceDirectoryStructure = new WorkSpaceDirectoryStructure();
|
2020-03-11 18:52:39 +01:00
|
|
|
FolderContainer targetFolder = workSpaceDirectoryStructure.getTargetFolder(aggregationType, date);
|
2017-09-05 17:13:50 +02:00
|
|
|
|
|
|
|
File file = new File(Constant.ROOT_DIRECTORY, "aux.txt");
|
2020-03-16 15:10:43 +01:00
|
|
|
List<File> files = new ArrayList<>();
|
|
|
|
files.add(file);
|
2017-09-05 17:13:50 +02:00
|
|
|
|
2020-03-16 15:10:43 +01:00
|
|
|
WorkSpaceManagement.getInstance().zipAndBackupFiles(targetFolder, "Test", files);
|
2017-09-05 17:13:50 +02:00
|
|
|
}
|
|
|
|
}
|