Search in sources :

Example 1 with PublicationSystem

use of cz.metacentrum.perun.cabinet.model.PublicationSystem in project perun by CESNET.

the class PublicationSystemStrategyIntegrationTest method contactPublicationSystemOBDTest.

@Test
public void contactPublicationSystemOBDTest() throws Exception {
    System.out.println("PublicationSystemStrategyIntegrationTest.contactPublicationSystemOBDTest");
    PublicationSystem publicationSystem = getCabinetManager().getPublicationSystemByNamespace("zcu");
    assertNotNull(publicationSystem);
    PublicationSystemStrategy prezentator = (PublicationSystemStrategy) Class.forName(publicationSystem.getType()).newInstance();
    assertNotNull(prezentator);
    PublicationSystemStrategy obd = (PublicationSystemStrategy) Class.forName(publicationSystem.getType()).newInstance();
    assertNotNull(obd);
    String authorId = "Sitera,Jiří";
    int yearSince = 2006;
    int yearTill = 2009;
    HttpUriRequest request = obd.getHttpRequest(authorId, yearSince, yearTill, publicationSystem);
    try {
        HttpResponse response = obd.execute(request);
        assertNotNull(response);
    } catch (CabinetException ex) {
        if (!ex.getType().equals(ErrorCodes.HTTP_IO_EXCEPTION)) {
            fail("Different exception code, was: " + ex.getType() + ", but expected: HTTP_IO_EXCEPTION.");
        // fail if different error
        } else {
            System.out.println("-- Test silently skipped because of HTTP_IO_EXCEPTION");
        }
    }
}
Also used : HttpUriRequest(org.apache.http.client.methods.HttpUriRequest) HttpResponse(org.apache.http.HttpResponse) PublicationSystem(cz.metacentrum.perun.cabinet.model.PublicationSystem) CabinetException(cz.metacentrum.perun.cabinet.bl.CabinetException) CabinetBaseIntegrationTest(cz.metacentrum.perun.cabinet.CabinetBaseIntegrationTest) Test(org.junit.Test)

Example 2 with PublicationSystem

use of cz.metacentrum.perun.cabinet.model.PublicationSystem in project perun by CESNET.

the class MUStrategyUnitTest method getHttpRequest.

@Test
public void getHttpRequest() throws Exception {
    System.out.println("MUStrategyUnitTest.getHttpRequest");
    PublicationSystem ps = new PublicationSystem();
    ps.setLoginNamespace("mu");
    ps.setUsername("test");
    ps.setPassword("test");
    ps.setUrl("http://www.seznam.cz");
    HttpUriRequest result = muStrategy.getHttpRequest("1", 2009, 2010, ps);
    assert result != null;
}
Also used : HttpUriRequest(org.apache.http.client.methods.HttpUriRequest) PublicationSystem(cz.metacentrum.perun.cabinet.model.PublicationSystem) Test(org.junit.Test)

Example 3 with PublicationSystem

use of cz.metacentrum.perun.cabinet.model.PublicationSystem in project perun by CESNET.

the class PublicationSystemManagerIntegrationTest method updatePublicationSystem.

@Test
public void updatePublicationSystem() throws Exception {
    System.out.println("PublicationSystemManagerIntegrationTest.updatePublicationSystem");
    PublicationSystem ps = new PublicationSystem();
    ps.setFriendlyName("PS for tests");
    ps.setLoginNamespace("some");
    ps.setUrl("http://seznam.cz");
    ps.setUsername("");
    ps.setPassword("");
    ps.setType("cz.metacentrum.perun.cabinet.strategy.impl.MUStrategy");
    ps = getCabinetManager().createPublicationSystem(sess, ps);
    PublicationSystem ps2 = getCabinetManager().getPublicationSystemById(ps.getId());
    assertEquals(ps, ps2);
    ps.setUrl("http://www.seznam.cz");
    ps = getCabinetManager().updatePublicationSystem(sess, ps);
    PublicationSystem ps3 = getCabinetManager().getPublicationSystemById(ps.getId());
    assertEquals(ps.getUrl(), ps3.getUrl());
    assertFalse(Objects.equals(ps2.getUrl(), ps3.getUrl()));
}
Also used : PublicationSystem(cz.metacentrum.perun.cabinet.model.PublicationSystem) Test(org.junit.Test)

Example 4 with PublicationSystem

use of cz.metacentrum.perun.cabinet.model.PublicationSystem in project perun by CESNET.

the class PublicationSystemManagerIntegrationTest method createPublicationSystem.

@Test
public void createPublicationSystem() throws Exception {
    System.out.println("PublicationSystemManagerIntegrationTest.createPublicationSystem");
    PublicationSystem ps = new PublicationSystem();
    ps.setFriendlyName("PS for tests");
    ps.setLoginNamespace("some");
    ps.setUrl("http://seznam.cz");
    ps.setUsername("");
    ps.setPassword("");
    ps.setType("cz.metacentrum.perun.cabinet.strategy.impl.MUStrategy");
    ps = getCabinetManager().createPublicationSystem(sess, ps);
    PublicationSystem ps2 = getCabinetManager().getPublicationSystemById(ps.getId());
    assertEquals(ps, ps2);
}
Also used : PublicationSystem(cz.metacentrum.perun.cabinet.model.PublicationSystem) Test(org.junit.Test)

Example 5 with PublicationSystem

use of cz.metacentrum.perun.cabinet.model.PublicationSystem in project perun by CESNET.

the class PublicationSystemManagerIntegrationTest method getPublicationSystemByNamespace.

@Test
public void getPublicationSystemByNamespace() throws Exception {
    System.out.println("PublicationSystemManagerIntegrationTest.getPublicationSystemByNamespace");
    PublicationSystem publicationSystem = getCabinetManager().getPublicationSystemByNamespace("mu");
    assertNotNull(publicationSystem);
    assertTrue(Objects.equals(publicationSystem, pubSysMu));
    PublicationSystemStrategy ps = (PublicationSystemStrategy) Class.forName(publicationSystem.getType()).newInstance();
    assertNotNull(ps);
}
Also used : PublicationSystem(cz.metacentrum.perun.cabinet.model.PublicationSystem) PublicationSystemStrategy(cz.metacentrum.perun.cabinet.strategy.PublicationSystemStrategy) Test(org.junit.Test)

Aggregations

PublicationSystem (cz.metacentrum.perun.cabinet.model.PublicationSystem)14 Test (org.junit.Test)9 CabinetException (cz.metacentrum.perun.cabinet.bl.CabinetException)3 Publication (cz.metacentrum.perun.cabinet.model.Publication)3 PublicationSystemStrategy (cz.metacentrum.perun.cabinet.strategy.PublicationSystemStrategy)3 CabinetBaseIntegrationTest (cz.metacentrum.perun.cabinet.CabinetBaseIntegrationTest)2 Date (java.util.Date)2 HttpResponse (org.apache.http.HttpResponse)2 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)2 Authorship (cz.metacentrum.perun.cabinet.model.Authorship)1 Category (cz.metacentrum.perun.cabinet.model.Category)1 UserNotExistsException (cz.metacentrum.perun.core.api.exceptions.UserNotExistsException)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1