Skip to content
Snippets Groups Projects
Commit 03c730f3 authored by pkupczyk's avatar pkupczyk
Browse files

SP-1226 / BIS-677 : Data Set Size Filling Maintenance Task - more tests

SVN: 30812
parent 58be03b9
No related branches found
No related tags found
No related merge requests found
......@@ -16,78 +16,37 @@
package ch.systemsx.cisd.etlserver.path;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;
import java.util.Date;
import java.util.List;
import net.lemnik.eodsql.QueryTool;
import org.testng.Assert;
import org.testng.annotations.Test;
import ch.systemsx.cisd.openbis.datastoreserver.systemtests.SystemTestCase;
import ch.systemsx.cisd.openbis.dss.generic.shared.utils.PathInfoDataSourceProvider;
/**
* This is a minimal test for {@link IPathsInfoDAO} which ensures that the query annotations can be
* parsed correctly.
*
* @author Bernd Rinn
* @author pkupczyk
*/
public class IPathsInfoDAOTest
public class IPathsInfoDAOTest extends SystemTestCase
{
private final DataSource DUMMY_DATA_SOURCE = new DataSource()
{
@Override
public Connection getConnection() throws SQLException
{
return null;
}
@Override
public Connection getConnection(String username, String password) throws SQLException
{
return null;
}
@Override
public PrintWriter getLogWriter() throws SQLException
{
return null;
}
@Test
public void testListDataSetsSize()
{
IPathsInfoDAO dao = QueryTool.getQuery(PathInfoDataSourceProvider.getDataSource(), IPathsInfoDAO.class);
@Override
public void setLogWriter(PrintWriter out) throws SQLException
{
}
long dataSetId = dao.createDataSet("DATA_SET_WITH_SIZE", "abc");
long rootDirectoryId = dao.createDataSetFile(dataSetId, null, "", "root", 123L, true, new Date());
dao.createDataSetFile(dataSetId, rootDirectoryId, "root", "file1.txt", 100L, false, new Date());
dao.createDataSetFile(dataSetId, rootDirectoryId, "root", "file2.txt", 23L, false, new Date());
@Override
public void setLoginTimeout(int seconds) throws SQLException
{
}
List<PathEntryDTO> entries = dao.listDataSetsSize(new String[] { "DATA_SET_WITH_SIZE" });
@Override
public int getLoginTimeout() throws SQLException
{
return 0;
}
@Override
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException
{
return null;
}
@Override
public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException
{
return false;
}
};
@Test
public void testGetQuery()
{
QueryTool.getQuery(DUMMY_DATA_SOURCE, IPathsInfoDAO.class);
Assert.assertEquals(1, entries.size());
Assert.assertEquals(Long.valueOf(123L), entries.get(0).getSizeInBytes());
}
}
......@@ -382,4 +382,10 @@ public abstract class SystemTestCase extends AssertJUnit
return logAppender;
}
@SuppressWarnings("unchecked")
protected static <T> T getBean(String beanName)
{
return (T) applicationContext.getBean(beanName);
}
}
/*
* Copyright 2014 ETH Zuerich, CISD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.systemsx.cisd.openbis.generic.server;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import junit.framework.Assert;
import org.testng.annotations.Test;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.AbstractExternalData;
import ch.systemsx.cisd.openbis.generic.shared.dto.SimpleDataSetInformationDTO;
import ch.systemsx.cisd.openbis.systemtest.SystemTestCase;
/**
* @author pkupczyk
*/
public class ServiceForDataStoreServerTest extends SystemTestCase
{
@Test()
public void testListPhysicalDataSetsWithUnknownSize()
{
String sessionToken = authenticateAs("test");
List<SimpleDataSetInformationDTO> dataSetsWithUnknownSize = etlService.listPhysicalDataSetsWithUnknownSize(sessionToken, "STANDARD");
sortByCode(dataSetsWithUnknownSize);
Assert.assertEquals(20, dataSetsWithUnknownSize.size());
Assert.assertEquals("20081105092159188-3", dataSetsWithUnknownSize.get(0).getDataSetCode());
Assert.assertEquals("VALIDATIONS_PARENT-28", dataSetsWithUnknownSize.get(dataSetsWithUnknownSize.size() - 1).getDataSetCode());
}
@Test(dependsOnMethods = "testListPhysicalDataSetsWithUnknownSize")
public void testUpdatePhysicalDataSetsWithUnknownSize()
{
String sessionToken = authenticateAs("test");
Map<String, Long> sizeMap = new HashMap<String, Long>();
sizeMap.put("20081105092159188-3", 123L);
etlService.updatePhysicalDataSetsSize(sessionToken, sizeMap);
List<SimpleDataSetInformationDTO> dataSetsWithUnknownSize = etlService.listPhysicalDataSetsWithUnknownSize(sessionToken, "STANDARD");
List<AbstractExternalData> updatedDataSets = etlService.listDataSetsByCode(sessionToken, Arrays.asList("20081105092159188-3"));
sortByCode(dataSetsWithUnknownSize);
Assert.assertEquals(19, dataSetsWithUnknownSize.size());
Assert.assertEquals("20081105092159222-2", dataSetsWithUnknownSize.get(0).getDataSetCode());
Assert.assertEquals("VALIDATIONS_PARENT-28", dataSetsWithUnknownSize.get(dataSetsWithUnknownSize.size() - 1).getDataSetCode());
Assert.assertEquals(1, updatedDataSets.size());
Assert.assertEquals("20081105092159188-3", updatedDataSets.get(0).getCode());
Assert.assertEquals(Long.valueOf(123L), updatedDataSets.get(0).getSize());
}
private void sortByCode(List<SimpleDataSetInformationDTO> dataSets)
{
Collections.sort(dataSets, new Comparator<SimpleDataSetInformationDTO>()
{
@Override
public int compare(SimpleDataSetInformationDTO o1, SimpleDataSetInformationDTO o2)
{
return o1.getDataSetCode().compareTo(o2.getDataSetCode());
}
});
}
}
......@@ -28,8 +28,6 @@ import ch.systemsx.cisd.openbis.plugin.proteomics.shared.ResourceNames;
import ch.systemsx.cisd.openbis.plugin.proteomics.shared.api.v1.IProteomicsDataService;
/**
*
*
* @author Franz-Josef Elmer
*/
public abstract class AbstractProteomicsSystemTestCase extends SystemTestCase
......@@ -53,7 +51,7 @@ public abstract class AbstractProteomicsSystemTestCase extends SystemTestCase
protected String registerPerson(String userID)
{
ICommonServerForInternalUse commonServer = getCommonServer();
String systemSessionToken = commonServer .tryToAuthenticateAsSystem().getSessionToken();
String systemSessionToken = commonServer.tryToAuthenticateAsSystem().getSessionToken();
commonServer.registerPerson(systemSessionToken, userID);
return userID;
}
......@@ -99,10 +97,4 @@ public abstract class AbstractProteomicsSystemTestCase extends SystemTestCase
return getBean(ResourceNames.PROTEOMICS_PLUGIN_SERVER);
}
@SuppressWarnings("unchecked")
private <T> T getBean(String beanId)
{
return (T) applicationContext.getBean(beanId);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment