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);
}
}
}
use of cz.metacentrum.perun.cabinet.model.Publication in project perun by CESNET.
the class MUStrategyUnitTest method parseResponse.
@Test
public void parseResponse() throws Exception {
System.out.println("MUStrategyUnitTest.parseResponse");
List<Publication> publications = muStrategy.parseResponse(muPublicationsResponse);
assertNotNull(publications);
assertEquals(4, publications.size());
Publication p = publications.get(0);
final String title = "Network Identity Manager Providers.";
final Integer year = 2009;
assertTrue(p.getMain().contains(title));
assertEquals(title, p.getTitle());
assertEquals("missing isbn should be default (=empty string)", "", p.getIsbn());
assertTrue(year == p.getYear());
assertNotNull(p.getExternalId());
assertTrue(p.getExternalId() > 0);
List<Author> authors = p.getAuthors();
assertEquals(5, authors.size());
assertTrue(authors.get(0) != null);
assertTrue(authors.get(1) != null);
assertTrue(authors.get(2) != null);
assertTrue(authors.get(3) != null);
assertTrue(authors.get(4) != null);
final String firstName = "Michal";
final String lastName = "Procházka";
Author a = authors.get(1);
assertEquals(firstName, a.getFirstName());
assertEquals(lastName, a.getLastName());
}
Aggregations