use of cz.metacentrum.perun.cabinet.model.Publication in project perun by CESNET.
the class PublicationManagerIntegrationTest method updatePublicationTest.
@Test
public void updatePublicationTest() throws Exception {
System.out.println("PublicationManagerIntegrationTest.updatePublicationTest");
publicationOne.setMain("NEW MAIN");
getCabinetManager().updatePublication(sess, publicationOne);
Publication pub = getCabinetManager().getPublicationById(publicationOne.getId());
assertEquals("Returned publication should be updated.", pub, publicationOne);
assertEquals("Returned publication should be updated.", pub.getMain(), publicationOne.getMain());
}
use of cz.metacentrum.perun.cabinet.model.Publication in project perun by CESNET.
the class PublicationManagerIntegrationTest method lockPublicationsTest.
@Test
public void lockPublicationsTest() throws Exception {
System.out.println("PublicationManagerIntegrationTest.lockPublicationsTest");
List<Publication> pubs = new ArrayList<Publication>();
pubs.add(publicationOne);
pubs.add(publicationTwo);
boolean lock = publicationOne.getLocked();
// switch lock to opposite
getCabinetManager().lockPublications(sess, !lock, pubs);
Publication result = getCabinetManager().getPublicationById(publicationOne.getId());
assertTrue("PublicationOne was not locked/unlocked", result.getLocked() != lock);
Publication result2 = getCabinetManager().getPublicationById(publicationTwo.getId());
assertTrue("PublicationTwo was not locked/unlocked", result2.getLocked() != lock);
}
use of cz.metacentrum.perun.cabinet.model.Publication in project perun by CESNET.
the class PublicationManagerIntegrationTest method updatePublicationWhenNotExistsTest.
@Test
public void updatePublicationWhenNotExistsTest() throws Exception {
System.out.println("PublicationManagerIntegrationTest.updatePublicationWhenNotExistsTest");
Publication pub = new Publication();
try {
getCabinetManager().updatePublication(sess, pub);
} catch (CabinetException ex) {
if (!ex.getType().equals(ErrorCodes.PUBLICATION_NOT_EXISTS)) {
fail("Different exception code, was: " + ex.getType() + ", but expected: PUBLICATION_NOT_EXISTS.");
// fail if different error
}
}
}
use of cz.metacentrum.perun.cabinet.model.Publication in project perun by CESNET.
the class PublicationManagerIntegrationTest method getPublicationByIdOrExtIdTest.
@Test
public void getPublicationByIdOrExtIdTest() throws Exception {
System.out.println("PublicationManagerIntegrationTest.getPublicationByIdOrExtIdTest");
// search base on publicationOne ID
Publication retrievedPub = getCabinetManager().getPublicationById(publicationOne.getId());
assertTrue("Returned publications can't be null or empty.", (retrievedPub != null));
assertTrue("Returned publication should be same as publicationOne.", Objects.equals(publicationOne, retrievedPub));
// search base on publicationOne EXT_ID, PUB_SYS_ID
retrievedPub = getCabinetManager().getPublicationByExternalId(publicationOne.getExternalId(), publicationOne.getPublicationSystemId());
assertTrue("Returned publications can't be null or empty.", (retrievedPub != null));
assertTrue("Returned publication should be same as publicationOne.", Objects.equals(publicationOne, retrievedPub));
}
use of cz.metacentrum.perun.cabinet.model.Publication in project perun by CESNET.
the class PublicationManagerIntegrationTest method createInternalPublicationTest.
@Test
public void createInternalPublicationTest() throws Exception {
System.out.println("PublicationManagerIntegrationTest.createInternalPublicationTest");
Publication p = new Publication();
p.setCategoryId(publicationOne.getCategoryId());
// Pepa id 10, userId 1
p.setCreatedBy(sess.getPerunPrincipal().getActor());
p.setCreatedDate(new Date());
// INTERNAL
p.setExternalId(0);
p.setIsbn("isbn 123-4556-899");
p.setMain("KERBEROS main zaznam.");
// INTERNAL
p.setPublicationSystemId(0);
p.setTitle("Kerberos");
p.setYear(2010);
p.setRank(0.0);
p.setLocked(false);
p.setDoi("DOI");
p.setCreatedByUid(sess.getPerunPrincipal().getUserId());
p = getCabinetManager().createPublication(sess, p);
assertTrue(p.getId() > 0);
// must be reset, since test update object after creation
p.setExternalId(0);
p.setPublicationSystemId(0);
// double-check existence (based on isbn)
try {
getCabinetManager().createPublication(sess, p);
} catch (CabinetException ex) {
if (!ex.getType().equals(ErrorCodes.PUBLICATION_ALREADY_EXISTS)) {
fail("Different exception was thrown when creating \"same\" internal publication: " + ex);
}
}
}
Aggregations