Skip to content
Snippets Groups Projects
Commit a32cfb18 authored by cramakri's avatar cramakri
Browse files

BIS-189 SP-467 : Added test

SVN: 28390
parent 2432ff67
No related branches found
No related tags found
No related merge requests found
/*
* Copyright 2012 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.systemtest;
import static org.testng.AssertJUnit.assertEquals;
import java.util.Collection;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Experiment;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Project;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Space;
import ch.systemsx.cisd.openbis.systemtest.base.BaseTest;
/**
* A test the moves a data set to the trash before post registration runs.
*
* @author cramakri
*/
public class DeleteDataSetBeforePostRegistrationTest extends BaseTest
{
Sample sample;
@Test
public void emptyTrashWithDataSetInPostRegistrationQueue() throws Exception
{
assertEquals(0, getDataSetsForPostRegistration().size());
ExternalData dataSet = create(aDataSet().inSample(sample));
daoFactory.getPostRegistrationDAO().addDataSet(dataSet.getCode());
assertEquals(1, getDataSetsForPostRegistration().size());
perform(trash(dataSet));
perform(emptyTrash());
assertEquals(0, getDataSetsForPostRegistration().size());
}
private Collection<Long> getDataSetsForPostRegistration()
{
return daoFactory.getPostRegistrationDAO().listDataSetsForPostRegistration();
}
@BeforeClass(dependsOnMethods = "loginAsSystem")
void createFixture() throws Exception
{
Space space = create(aSpace());
Project project = create(aProject().inSpace(space));
Experiment experiment = create(anExperiment().inProject(project));
sample = create(aSample().inExperiment(experiment));
}
}
......@@ -63,6 +63,7 @@ import ch.systemsx.cisd.openbis.systemtest.base.auth.GuardedDomain;
import ch.systemsx.cisd.openbis.systemtest.base.auth.NotAuthorizationRule;
import ch.systemsx.cisd.openbis.systemtest.base.auth.OrAuthorizationRule;
import ch.systemsx.cisd.openbis.systemtest.base.builder.Builder;
import ch.systemsx.cisd.openbis.systemtest.base.builder.DataSetDeletionBuilder;
import ch.systemsx.cisd.openbis.systemtest.base.builder.DataSetUpdateBuilder;
import ch.systemsx.cisd.openbis.systemtest.base.builder.ExperimentBuilder;
import ch.systemsx.cisd.openbis.systemtest.base.builder.ExperimentUpdateBuilder;
......@@ -73,6 +74,7 @@ import ch.systemsx.cisd.openbis.systemtest.base.builder.SampleBuilder;
import ch.systemsx.cisd.openbis.systemtest.base.builder.SampleUpdateBuilder;
import ch.systemsx.cisd.openbis.systemtest.base.builder.SessionBuilder;
import ch.systemsx.cisd.openbis.systemtest.base.builder.SpaceBuilder;
import ch.systemsx.cisd.openbis.systemtest.base.builder.TrashEmptyBuilder;
import ch.systemsx.cisd.openbis.systemtest.base.builder.UpdateBuilder;
import ch.systemsx.cisd.openbis.systemtest.base.matcher.ExternalDataHasChildrenMatcher;
import ch.systemsx.cisd.openbis.systemtest.base.matcher.ExternalDataHasContainerMatcher;
......@@ -280,6 +282,16 @@ public abstract class BaseTest extends AbstractTransactionalTestNGSpringContextT
return new DataSetUpdateBuilder(commonServer, genericServer, refresh(dataset));
}
protected DataSetDeletionBuilder trash(ExternalData dataset)
{
return new DataSetDeletionBuilder(commonServer, genericServer, refresh(dataset));
}
protected TrashEmptyBuilder emptyTrash()
{
return new TrashEmptyBuilder(commonServer, genericServer);
}
protected SessionBuilder aSession()
{
return new SessionBuilder(commonServer, genericServer);
......
/*
* Copyright 2012 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.systemtest.base.builder;
import java.util.Collections;
import java.util.List;
import ch.systemsx.cisd.openbis.generic.server.ICommonServerForInternalUse;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DeletionType;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData;
import ch.systemsx.cisd.openbis.plugin.generic.shared.IGenericServer;
/**
* A builder that puts a data set into the trash.
*
* @author cramakri
*/
public class DataSetDeletionBuilder extends UpdateBuilder<List<String>>
{
private String dataSetCode;
public DataSetDeletionBuilder(ICommonServerForInternalUse commonServer,
IGenericServer genericServer, ExternalData data)
{
super(commonServer, genericServer);
this.dataSetCode = data.getCode();
}
@Override
public List<String> create()
{
return Collections.singletonList(dataSetCode);
}
@Override
public void perform()
{
commonServer.deleteDataSets(this.sessionToken, this.create(), "Test", DeletionType.TRASH,
true);
}
}
\ No newline at end of file
/*
* Copyright 2012 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.systemtest.base.builder;
import java.util.List;
import ch.systemsx.cisd.openbis.generic.server.ICommonServerForInternalUse;
import ch.systemsx.cisd.openbis.generic.shared.basic.TechId;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Deletion;
import ch.systemsx.cisd.openbis.plugin.generic.shared.IGenericServer;
/**
* A builder that empties the trash.
*
* @author cramakri
*/
public class TrashEmptyBuilder extends UpdateBuilder<String>
{
public TrashEmptyBuilder(ICommonServerForInternalUse commonServer, IGenericServer genericServer)
{
super(commonServer, genericServer);
}
@Override
public String create()
{
return "";
}
@Override
public void perform()
{
List<Deletion> deletions = commonServer.listDeletions(sessionToken, false);
commonServer.deletePermanently(sessionToken, TechId.createList(deletions));
}
}
\ 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