use of org.sagebionetworks.bridge.models.assessments.HibernateAssessment in project BridgeServer2 by Sage-Bionetworks.
the class HibernateAssessmentConfigDao method updateAssessmentConfig.
@Override
public AssessmentConfig updateAssessmentConfig(String appId, Assessment assessment, String guid, AssessmentConfig config) {
HibernateAssessment hibAssessment = HibernateAssessment.create(appId, assessment);
HibernateAssessmentConfig hibConfig = HibernateAssessmentConfig.create(guid, config);
HibernateAssessmentConfig retValue = hibernateHelper.executeWithExceptionHandling(hibConfig, (session) -> {
session.merge(hibAssessment);
session.merge(hibConfig);
// the merge method does not do this like the save method.
return session.get(HibernateAssessmentConfig.class, hibConfig.getGuid());
});
return AssessmentConfig.create(retValue);
}
use of org.sagebionetworks.bridge.models.assessments.HibernateAssessment in project BridgeServer2 by Sage-Bionetworks.
the class HibernateAssessmentDaoTest method publishAssessment.
@Test
public void publishAssessment() throws Exception {
Assessment original = new Assessment();
Assessment assessmentToPublish = AssessmentTest.createAssessment();
AssessmentConfig originConfig = new AssessmentConfig();
when(mockSession.merge(any())).thenReturn(new HibernateAssessment());
Assessment retValue = dao.publishAssessment(TEST_APP_ID, original, assessmentToPublish, originConfig);
assertNotNull(retValue);
verify(mockHelper).executeWithExceptionHandling(any(HibernateAssessment.class), any());
verify(mockSession).saveOrUpdate(any(HibernateAssessmentConfig.class));
verify(mockSession).saveOrUpdate(any(HibernateAssessment.class));
}
use of org.sagebionetworks.bridge.models.assessments.HibernateAssessment in project BridgeServer2 by Sage-Bionetworks.
the class TagEventListenerTest method onSaveOrUpdateNotTag.
@Test
public void onSaveOrUpdateNotTag() throws HibernateException {
SaveOrUpdateEvent event = new SaveOrUpdateEvent(new HibernateAssessment(), null);
listener.onSaveOrUpdate(event);
verify(cacheProvider, never()).removeObject(CacheKey.tagList());
}
use of org.sagebionetworks.bridge.models.assessments.HibernateAssessment in project BridgeServer2 by Sage-Bionetworks.
the class TagEventListenerTest method onPersistNotTag.
@Test
public void onPersistNotTag() throws HibernateException {
PersistEvent event = new PersistEvent(new HibernateAssessment(), null);
listener.onPersist(event);
verify(cacheProvider, never()).removeObject(CacheKey.tagList());
}
use of org.sagebionetworks.bridge.models.assessments.HibernateAssessment in project BridgeServer2 by Sage-Bionetworks.
the class MySQLHibernatePersistenceExceptionConverterTest method sqlIntegrityConstraintViolation_AssessmentRefAssessmentConstraint.
@Test
public void sqlIntegrityConstraintViolation_AssessmentRefAssessmentConstraint() {
PersistenceException pe = buildIntegrityConstraintViolation("AssessmentRef-Assessment-Cosntraint", "a foreign key constraint fails ... AssessmentRef-Assessment-Constraint`");
HibernateAssessment assessment = new HibernateAssessment();
BridgeServiceException converted = (BridgeServiceException) converter.convert(pe, assessment);
assertEquals(converted.getMessage(), "This assessment cannot be deleted or updated because it is referenced by a scheduling session.");
assertEquals(converted.getStatusCode(), HttpStatus.SC_CONFLICT);
assertEquals(converted.getClass().getSimpleName(), "ConstraintViolationException");
}
Aggregations