Skip to content
Snippets Groups Projects
Commit 54b455a2 authored by piotr.kupczyk@id.ethz.ch's avatar piotr.kupczyk@id.ethz.ch
Browse files

SSDM-11859 : openBIS core : reverting a deletion via coreUI or ELN is very inefficient - fix tests

parent 60f26685
No related branches found
No related tags found
No related merge requests found
......@@ -57,7 +57,7 @@ public abstract class DeletionTechIdCollectionPredicateSystemTest extends Common
{
for (TechId object : objects)
{
if (object != null)
if (object != null && !object.equals(this.createNonexistentObject(param)))
{
getCommonService().untrash(object.getId());
}
......@@ -70,31 +70,31 @@ public abstract class DeletionTechIdCollectionPredicateSystemTest extends Common
protected CommonPredicateSystemTestAssertions<TechId> getAssertions()
{
return new CommonPredicateSystemTestAssertionsDelegate<TechId>(super.getAssertions())
{
@Override
public void assertWithNullObject(ProjectAuthorizationUser user, Throwable t, Object param)
{
@Override
public void assertWithNullObject(ProjectAuthorizationUser user, Throwable t, Object param)
if (user.isDisabledProjectUser())
{
if (user.isDisabledProjectUser())
{
assertAuthorizationFailureExceptionThatNoRoles(t);
} else
{
assertException(t, NullPointerException.class, null);
}
assertAuthorizationFailureExceptionThatNoRoles(t);
} else
{
assertException(t, NullPointerException.class, null);
}
}
@Override
public void assertWithNullCollection(ProjectAuthorizationUser user, Throwable t, Object param)
@Override
public void assertWithNullCollection(ProjectAuthorizationUser user, Throwable t, Object param)
{
if (user.isDisabledProjectUser())
{
if (user.isDisabledProjectUser())
{
assertAuthorizationFailureExceptionThatNoRoles(t);
} else
{
assertException(t, UserFailureException.class, "No deletion technical id specified.");
}
assertAuthorizationFailureExceptionThatNoRoles(t);
} else
{
assertException(t, UserFailureException.class, "No deletion technical id specified.");
}
};
}
};
}
}
\ No newline at end of file
......@@ -57,7 +57,7 @@ public abstract class RevertDeletionPredicateSystemTest extends CommonPredicateS
{
for (TechId object : objects)
{
if (object != null)
if (object != null && !object.equals(this.createNonexistentObject(param)))
{
getCommonService().untrash(object.getId());
}
......@@ -70,35 +70,35 @@ public abstract class RevertDeletionPredicateSystemTest extends CommonPredicateS
protected CommonPredicateSystemTestAssertions<TechId> getAssertions()
{
return new CommonPredicateSystemTestAssertionsDelegate<TechId>(super.getAssertions())
{
@Override
public void assertWithNullObject(ProjectAuthorizationUser user, Throwable t, Object param)
{
@Override
public void assertWithNullObject(ProjectAuthorizationUser user, Throwable t, Object param)
if (user.isDisabledProjectUser())
{
if (user.isDisabledProjectUser())
{
assertAuthorizationFailureExceptionThatNoRoles(t);
} else if (user.isInstanceUser())
{
assertNoException(t);
} else
{
assertException(t, NullPointerException.class, null);
}
assertAuthorizationFailureExceptionThatNoRoles(t);
} else if (user.isInstanceUser())
{
assertNoException(t);
} else
{
assertException(t, NullPointerException.class, null);
}
}
@Override
public void assertWithNullCollection(ProjectAuthorizationUser user, Throwable t, Object param)
@Override
public void assertWithNullCollection(ProjectAuthorizationUser user, Throwable t, Object param)
{
if (user.isDisabledProjectUser())
{
if (user.isDisabledProjectUser())
{
assertAuthorizationFailureExceptionThatNoRoles(t);
} else
{
assertException(t, UserFailureException.class, "No revert deletion technical id specified.");
}
assertAuthorizationFailureExceptionThatNoRoles(t);
} else
{
assertException(t, UserFailureException.class, "No revert deletion technical id specified.");
}
}
};
};
}
}
\ No newline at end of file
......@@ -57,7 +57,7 @@ public abstract class V3DeletionIdPredicateSystemTest extends CommonPredicateSys
{
for (IDeletionId object : objects)
{
if (object != null)
if (object != null && !object.equals(this.createNonexistentObject(param)))
{
getCommonService().untrash(((DeletionTechId) object).getTechId());
}
......@@ -70,32 +70,32 @@ public abstract class V3DeletionIdPredicateSystemTest extends CommonPredicateSys
protected CommonPredicateSystemTestAssertions<IDeletionId> getAssertions()
{
return new CommonPredicateSystemTestAssertionsDelegate<IDeletionId>(super.getAssertions())
{
@Override
public void assertWithNullObject(ProjectAuthorizationUser user, Throwable t, Object param)
{
@Override
public void assertWithNullObject(ProjectAuthorizationUser user, Throwable t, Object param)
if (user.isDisabledProjectUser())
{
if (user.isDisabledProjectUser())
{
assertAuthorizationFailureExceptionThatNoRoles(t);
} else
{
assertException(t, NullPointerException.class, null);
}
assertAuthorizationFailureExceptionThatNoRoles(t);
} else
{
assertException(t, NullPointerException.class, null);
}
}
@Override
public void assertWithNullCollection(ProjectAuthorizationUser user, Throwable t, Object param)
@Override
public void assertWithNullCollection(ProjectAuthorizationUser user, Throwable t, Object param)
{
if (user.isDisabledProjectUser())
{
if (user.isDisabledProjectUser())
{
assertAuthorizationFailureExceptionThatNoRoles(t);
} else
{
assertException(t, UserFailureException.class, "No v3 deletion id object specified.");
}
assertAuthorizationFailureExceptionThatNoRoles(t);
} else
{
assertException(t, UserFailureException.class, "No v3 deletion id object specified.");
}
}
};
};
}
}
\ No newline at end of file
......@@ -37,6 +37,7 @@ public class ServerInterfaceRegressionTest extends AnnotationAppliedTestCase
{
List<String> exemptMethods = new ArrayList<String>();
exemptMethods.add("getDisabledText");
exemptMethods.add("revertDeletions");
assertMandatoryMethodAnnotations(ICommonServer.class, CommonServer.class,
"getLastModificationState: Transactional\n", exemptMethods);
......
......@@ -33,6 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import ch.ethz.sis.openbis.generic.asapi.v3.exceptions.UnauthorizedObjectAccessException;
import ch.systemsx.cisd.common.exceptions.AuthorizationFailureException;
import ch.systemsx.cisd.common.exceptions.UserFailureException;
import ch.systemsx.cisd.common.test.AssertionUtil;
......@@ -76,7 +77,6 @@ import ch.systemsx.cisd.openbis.systemtest.PropertyHistory;
import ch.systemsx.cisd.openbis.systemtest.SystemTestCase;
import ch.systemsx.cisd.openbis.systemtest.authorization.ProjectAuthorizationUser;
import ch.systemsx.cisd.openbis.util.GeneralInformationServiceUtil;
import junit.framework.Assert;
/**
......@@ -117,7 +117,7 @@ public class GeneralInformationChangingServiceTest extends SystemTestCase
localCommonServer.assignPropertyType(sessionToken, new NewETPTAssignment(EntityKind.SAMPLE,
"GENDER", "CELL_PLATE", false, null, null, 1L, false, false, null, true, false));
assertProperties("[ANY_MATERIAL: 2 (GENE), BACTERIUM: BACTERIUM-Y (BACTERIUM), "
+ "COMMENT: extremely simple stuff, ORGANISM: GORILLA, SIZE: 321]",
+ "COMMENT: extremely simple stuff, ORGANISM: GORILLA, SIZE: 321]",
localCommonServer.getSampleInfo(sessionToken, id).getParent());
HashMap<String, String> properties = new HashMap<String, String>();
properties.put("SIZE", "42");
......@@ -132,7 +132,7 @@ public class GeneralInformationChangingServiceTest extends SystemTestCase
assertProperties("[ANY_MATERIAL: 1 (GENE), BACTERIUM: BACTERIUM-Y (BACTERIUM), "
+ "COMMENT: extremely simple stuff, DESCRIPTION: hello example, GENDER: FEMALE, "
+ "ORGANISM: DOG, SIZE: 42]", localCommonServer.getSampleInfo(sessionToken, id)
.getParent());
.getParent());
List<PropertyHistory> history = getSamplePropertiesHistory(id.getId());
assertEquals(
......@@ -147,7 +147,7 @@ public class GeneralInformationChangingServiceTest extends SystemTestCase
TechId id = new TechId(1043L);
ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample sampleBefore = localCommonServer.getSampleInfo(sessionToken, id).getParent();
assertProperties("[ANY_MATERIAL: 2 (GENE), BACTERIUM: BACTERIUM-Y (BACTERIUM), "
+ "COMMENT: extremely simple stuff, ORGANISM: GORILLA, SIZE: 321]",
+ "COMMENT: extremely simple stuff, ORGANISM: GORILLA, SIZE: 321]",
sampleBefore);
NewETPTAssignment newETPTAssignment = new NewETPTAssignment();
newETPTAssignment.setEntityKind(EntityKind.SAMPLE);
......@@ -164,7 +164,7 @@ public class GeneralInformationChangingServiceTest extends SystemTestCase
Session hibernateSession = getHibernateSession();
hibernateSession.clear();
assertProperties("[ANY_MATERIAL: 2 (GENE), BACTERIUM: BACTERIUM-Y (BACTERIUM), "
+ "COMMENT: extremely simple stuff, GENDER: FEMALE, ORGANISM: GORILLA, SIZE: 321]",
+ "COMMENT: extremely simple stuff, GENDER: FEMALE, ORGANISM: GORILLA, SIZE: 321]",
localCommonServer.getSampleInfo(sessionToken, id).getParent());
List<Vocabulary> listVocabularies = generalInformationService.listVocabularies(sessionToken);
......@@ -187,7 +187,7 @@ public class GeneralInformationChangingServiceTest extends SystemTestCase
replacement.setReplacementCode("MALE");
localCommonServer.deleteVocabularyTerms(sessionToken, new TechId(genderVocab.getId()),
Collections.<VocabularyTerm> emptyList(), Arrays.asList(replacement));
Collections.<VocabularyTerm>emptyList(), Arrays.asList(replacement));
ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample sampleAfter = localCommonServer.getSampleInfo(sessionToken, id)
.getParent();
......@@ -205,7 +205,7 @@ public class GeneralInformationChangingServiceTest extends SystemTestCase
TechId id = new TechId(1043L);
ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample sampleBefore = localCommonServer.getSampleInfo(sessionToken, id).getParent();
assertProperties("[ANY_MATERIAL: 2 (GENE), BACTERIUM: BACTERIUM-Y (BACTERIUM), "
+ "COMMENT: extremely simple stuff, ORGANISM: GORILLA, SIZE: 321]",
+ "COMMENT: extremely simple stuff, ORGANISM: GORILLA, SIZE: 321]",
sampleBefore);
NewETPTAssignment newETPTAssignment = new NewETPTAssignment();
newETPTAssignment.setEntityKind(EntityKind.SAMPLE);
......@@ -238,7 +238,7 @@ public class GeneralInformationChangingServiceTest extends SystemTestCase
TechId id = new TechId(1043L);
ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample sampleBefore = localCommonServer.getSampleInfo(sessionToken, id).getParent();
assertProperties("[ANY_MATERIAL: 2 (GENE), BACTERIUM: BACTERIUM-Y (BACTERIUM), "
+ "COMMENT: extremely simple stuff, ORGANISM: GORILLA, SIZE: 321]",
+ "COMMENT: extremely simple stuff, ORGANISM: GORILLA, SIZE: 321]",
sampleBefore);
localCommonServer.unassignPropertyType(sessionToken, EntityKind.SAMPLE, "COMMENT", "CELL_PLATE");
getHibernateSession().clear();
......@@ -1025,8 +1025,15 @@ public class GeneralInformationChangingServiceTest extends SystemTestCase
{
generalInformationChangingService.revertDeletions(session, Arrays.asList(deletion.getId()));
fail();
} catch (AuthorizationFailureException e)
} catch (UserFailureException e)
{
if (e.getCause() instanceof AuthorizationFailureException || e.getCause() instanceof UnauthorizedObjectAccessException)
{
// expected
} else
{
throw e;
}
}
}
}
......
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