Search in sources :

Example 86 with Transactional

use of org.springframework.transaction.annotation.Transactional in project opennms by OpenNMS.

the class DaoWebOutageRepositoryIT method testCountMatchingOutages.

@Test
@Transactional
public void testCountMatchingOutages() {
    int count = m_daoOutageRepo.countMatchingOutages(new OutageCriteria());
    assertEquals(3, count);
    count = m_daoOutageRepo.countMatchingOutages(new OutageCriteria(new RegainedServiceDateBeforeFilter(new Date())));
    assertEquals(1, count);
}
Also used : OutageCriteria(org.opennms.web.outage.filter.OutageCriteria) RegainedServiceDateBeforeFilter(org.opennms.web.outage.filter.RegainedServiceDateBeforeFilter) Date(java.util.Date) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 87 with Transactional

use of org.springframework.transaction.annotation.Transactional in project opennms by OpenNMS.

the class NetworkElementFactoryIT method testGetNodesWithIpLikeOneInterface.

@Test
@Transactional
@JUnitTemporaryDatabase
public void testGetNodesWithIpLikeOneInterface() throws Exception {
    // setUp() creates nodes by default, start with a clean slate
    for (final OnmsNode node : m_nodeDao.findAll()) {
        m_nodeDao.delete(node);
    }
    m_nodeDao.flush();
    m_jdbcTemplate.update("INSERT INTO node (location, nodeId, nodeCreateTime, nodeType) VALUES ('" + MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID + "', 12, now(), 'A')");
    m_jdbcTemplate.update("INSERT INTO ipInterface (nodeId, ipAddr, isManaged) VALUES (12, '1.1.1.1', 'M')");
    final List<OnmsNode> nodes = NetworkElementFactory.getInstance(m_appContext).getNodesWithIpLike("*.*.*.*");
    assertEquals("node count", 1, nodes.size());
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase) Transactional(org.springframework.transaction.annotation.Transactional)

Example 88 with Transactional

use of org.springframework.transaction.annotation.Transactional in project opennms by OpenNMS.

the class WebNotificationRepositoryFilterIT method testUserFilter.

@Test
@Transactional
public void testUserFilter() {
    UserFilter filter = new UserFilter("TestUser");
    assert1Result(filter);
}
Also used : UserFilter(org.opennms.web.notification.filter.UserFilter) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 89 with Transactional

use of org.springframework.transaction.annotation.Transactional in project opennms by OpenNMS.

the class DaoWebNotificationRepositoryIT method testAcknowledgeNotification.

@Test
@Transactional
public void testAcknowledgeNotification() {
    m_daoNotificationRepo.acknowledgeMatchingNotification("TestUser", new Date(), new NotificationCriteria());
    int notifCount = m_daoNotificationRepo.countMatchingNotifications(new NotificationCriteria(new AcknowledgedByFilter("TestUser")));
    assertEquals(1, notifCount);
    Notification[] notif = m_daoNotificationRepo.getMatchingNotifications(new NotificationCriteria(new AcknowledgedByFilter("TestUser")));
    assertEquals(1, notif.length);
    assertEquals("TestUser", notif[0].m_responder);
}
Also used : NotificationCriteria(org.opennms.web.notification.filter.NotificationCriteria) AcknowledgedByFilter(org.opennms.web.notification.filter.AcknowledgedByFilter) Date(java.util.Date) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 90 with Transactional

use of org.springframework.transaction.annotation.Transactional in project perun by CESNET.

the class RegistrarBaseIntegrationTest method createVOformIntegrationTest.

@Test
@Transactional
public void createVOformIntegrationTest() throws PerunException, PrivilegeException, InternalErrorException {
    System.out.println("createVOformIntegrationTest()");
    // get form for VO (if not exists, it's created)
    ApplicationForm applicationForm = registrarManager.getFormForVo(vo);
    // put in standard options
    ApplicationFormItem i0 = new ApplicationFormItem();
    i0.setShortname("pokecI");
    i0.setType(ApplicationFormItem.Type.HTML_COMMENT);
    i0.getTexts(CS).setLabel("Vyplňte, prosím, přihlášku.");
    i0.getTexts(EN).setLabel("Fill in the initial application, please.");
    i0.setApplicationTypes(Arrays.asList(Application.AppType.INITIAL));
    registrarManager.addFormItem(session, applicationForm, i0);
    ApplicationFormItem i0b = new ApplicationFormItem();
    i0b.setShortname("pokecE");
    i0b.setType(ApplicationFormItem.Type.HTML_COMMENT);
    i0b.getTexts(CS).setLabel("Zkontrolujte, prosím, před podáním žádosti o prodloužení účtu, svoje údaje.");
    i0b.getTexts(EN).setLabel("Please check you personal data before applying for account extension.");
    i0b.setApplicationTypes(Arrays.asList(Application.AppType.EXTENSION));
    registrarManager.addFormItem(session, applicationForm, i0b);
    ApplicationFormItem i1 = new ApplicationFormItem();
    i1.setShortname("titleBefore");
    i1.setPerunDestinationAttribute("urn:perun:user:attribute-def:core:titleBefore");
    i1.setRequired(false);
    i1.setType(ApplicationFormItem.Type.TEXTFIELD);
    i1.getTexts(CS).setLabel("Titul před jménem");
    i1.getTexts(CS).setHelp("Ing.,RNDr.,pplk., atd.");
    i1.getTexts(EN).setLabel("Title before name");
    registrarManager.addFormItem(session, applicationForm, i1);
    ApplicationFormItem i2 = new ApplicationFormItem();
    i2.setShortname("displayName");
    i2.setPerunDestinationAttribute("urn:perun:user:attribute-def:core:displayName");
    i2.setType(ApplicationFormItem.Type.FROM_FEDERATION_HIDDEN);
    i2.setRequired(true);
    i2.setFederationAttribute("Shib-Person-displayName");
    registrarManager.addFormItem(session, applicationForm, i2);
    ApplicationFormItem i2a = new ApplicationFormItem();
    i2a.setShortname("firstName");
    i2a.setPerunDestinationAttribute("urn:perun:user:attribute-def:core:firstName");
    i2a.setType(ApplicationFormItem.Type.TEXTFIELD);
    i2a.setRequired(true);
    i2a.setFederationAttribute("Shib-Person-givenName");
    i2a.getTexts(CS).setLabel("Jméno");
    i2a.getTexts(EN).setLabel("First name");
    registrarManager.addFormItem(session, applicationForm, i2a);
    ApplicationFormItem i2b = new ApplicationFormItem();
    i2b.setShortname("lastName");
    i2b.setPerunDestinationAttribute("urn:perun:user:attribute-def:core:lastName");
    i2b.setType(ApplicationFormItem.Type.TEXTFIELD);
    i2b.setRequired(true);
    i2b.setFederationAttribute("Shib-Person-sureName");
    i2b.getTexts(CS).setLabel("Příjmení");
    i2b.getTexts(EN).setLabel("Last name");
    registrarManager.addFormItem(session, applicationForm, i2b);
    ApplicationFormItem i3 = new ApplicationFormItem();
    i3.setShortname("titleAfter");
    i3.setPerunDestinationAttribute("urn:perun:user:attribute-def:core:titleAfter");
    i3.setRequired(false);
    i3.setType(ApplicationFormItem.Type.TEXTFIELD);
    i3.getTexts(CS).setLabel("Titul za jménem");
    i3.getTexts(CS).setHelp("Ph.D., CSc., DrSc., atd.");
    i3.getTexts(EN).setLabel("Title after name");
    registrarManager.addFormItem(session, applicationForm, i3);
    ApplicationFormItem i4 = new ApplicationFormItem();
    i4.setShortname("preferredMail");
    i4.setPerunDestinationAttribute("urn:perun:user:attribute-def:def:preferredMail");
    i4.setRequired(true);
    i4.setType(ApplicationFormItem.Type.VALIDATED_EMAIL);
    i4.getTexts(CS).setLabel("Email");
    i4.getTexts(CS).setHelp("Bude ověřen zasláním zprávy.");
    i4.getTexts(EN).setLabel("Email");
    i4.getTexts(EN).setHelp("Will be validated by sending an email message.");
    registrarManager.addFormItem(session, applicationForm, i4);
    ApplicationFormItem i5 = new ApplicationFormItem();
    i5.setShortname("organization");
    i5.setPerunDestinationAttribute("urn:perun:user:attribute-def:def:organization");
    i5.setType(ApplicationFormItem.Type.FROM_FEDERATION_SHOW);
    i5.setRequired(true);
    i5.setFederationAttribute("Shib-Person-o");
    i5.getTexts(CS).setLabel("Organizace");
    i5.getTexts(EN).setLabel("Organisation");
    registrarManager.addFormItem(session, applicationForm, i5);
    ApplicationFormItem i5b = new ApplicationFormItem();
    i5b.setShortname("affiliation");
    i5b.setPerunDestinationAttribute("urn:perun:member:attribute-def:opt:eduPersonAffiliation");
    i5b.setType(ApplicationFormItem.Type.FROM_FEDERATION_HIDDEN);
    i5b.setRequired(true);
    i5b.setFederationAttribute("Shib-EP-Affiliation");
    registrarManager.addFormItem(session, applicationForm, i5b);
    ApplicationFormItem i5c = new ApplicationFormItem();
    i5c.setShortname("mail");
    i5c.setPerunDestinationAttribute("urn:perun:user:attribute-def:def:mail");
    i5c.setType(ApplicationFormItem.Type.FROM_FEDERATION_HIDDEN);
    i5c.setRequired(true);
    i5c.setFederationAttribute("Shib-InetOrgPerson-mail");
    registrarManager.addFormItem(session, applicationForm, i5c);
    ApplicationFormItem i6 = new ApplicationFormItem();
    i6.setShortname("vyuziti");
    i6.setPerunDestinationAttribute("urn:perun:member:attribute-def:opt:registrationNote");
    i6.setRequired(true);
    i6.setType(ApplicationFormItem.Type.TEXTAREA);
    i6.getTexts(CS).setLabel("Popis plánovaného využití MetaCentra");
    i6.getTexts(CS).setHelp("Uveďte stručně, jakou činností se hodláte v MetaCentru zabývat. Uveďte také Vaše nadstandardní požadavky, požadavky, které nejsou pokryty položkami formuláře, případně jiné skutečnosti, které považujete za podstatné pro vyřízení přihlášky.");
    i6.getTexts(EN).setLabel("Description of planned activity");
    i6.getTexts(EN).setHelp("Describe shortly activity which you plane to perform at MetaCentrum. Mention your nonstandard demands, requests which are not covered in this form, eventually anything you consider important for this registration too.");
    registrarManager.addFormItem(session, applicationForm, i6);
    ApplicationFormItem i7 = new ApplicationFormItem();
    i7.setShortname("phone");
    i7.setPerunDestinationAttribute("urn:perun:user:attribute-def:def:phone");
    i7.setRequired(true);
    i7.setRegex("\\+*[0-9 ]*");
    i7.setType(ApplicationFormItem.Type.TEXTFIELD);
    i7.getTexts(CS).setLabel("Telefon");
    i7.getTexts(EN).setLabel("Phone");
    registrarManager.addFormItem(session, applicationForm, i7);
    ApplicationFormItem i8 = new ApplicationFormItem();
    i8.setShortname("workplace");
    i8.setPerunDestinationAttribute("urn:perun:user:attribute-def:def:workplace");
    i8.setRequired(true);
    i8.setType(ApplicationFormItem.Type.TEXTAREA);
    i8.getTexts(CS).setLabel("Katedra/ústav/výzkumná skupina");
    i8.getTexts(EN).setLabel("Department/research group");
    registrarManager.addFormItem(session, applicationForm, i8);
    ApplicationFormItem i9 = new ApplicationFormItem();
    i9.setShortname("jazyk");
    i9.setPerunDestinationAttribute("urn:perun:user:attribute-def:def:preferredLanguage");
    i9.setRequired(true);
    i9.setType(ApplicationFormItem.Type.SELECTIONBOX);
    i9.getTexts(CS).setLabel("Preferovaný jazyk");
    i9.getTexts(CS).setHelp("Zvolte jazyk, ve kterém chcete dostávát novinky a upozornění.");
    i9.getTexts(CS).setOptions("cs#česky|en#anglicky");
    i9.getTexts(EN).setLabel("Preffered language");
    i9.getTexts(EN).setHelp("Choose the language in which you want to receive news and notifications.");
    i9.getTexts(EN).setOptions("en#English|cs#Czech");
    registrarManager.addFormItem(session, applicationForm, i9);
    ApplicationFormItem i10 = new ApplicationFormItem();
    i10.setShortname("username");
    i10.setRequired(true);
    i10.setRegex("[a-z][a-z0-9_]+");
    i10.setType(ApplicationFormItem.Type.TEXTFIELD);
    i10.setPerunDestinationAttribute("urn:perun:user:attribute-def:def:login-namespace:meta");
    i10.getTexts(CS).setLabel("Zvolte si uživatelské jméno");
    i10.getTexts(CS).setHelp("Uživatelské jméno musí začínat malým písmenem, a obsahovat pouze malá písmena, číslice a podtržení. Doporučujeme délku nanejvýš 8 znaků.");
    i10.getTexts(EN).setLabel("Choose you user name");
    i10.getTexts(EN).setHelp("User name must begin with a small letter, and can contain only small letters, digits and underscores. We recommend length max 8 characters.");
    i10.setApplicationTypes(Arrays.asList(Application.AppType.INITIAL));
    registrarManager.addFormItem(session, applicationForm, i10);
    ApplicationFormItem i11 = new ApplicationFormItem();
    i11.setShortname("heslo");
    i11.setRequired(true);
    i11.setRegex("\\p{Print}{8,20}");
    i11.setType(ApplicationFormItem.Type.PASSWORD);
    i11.getTexts(CS).setLabel("Heslo");
    i11.getTexts(CS).setHelp("Heslo musí být 8 až 20 znaků dlouhé, a obsahovat aspoň 3 písmena a 1 znak jiný než písmeno.");
    i11.getTexts(EN).setLabel("Password");
    i11.getTexts(EN).setHelp("Password must be from 8 up to 20 characters long and contain printable characters only.");
    i11.setApplicationTypes(Arrays.asList(Application.AppType.INITIAL));
    registrarManager.addFormItem(session, applicationForm, i11);
    ApplicationFormItem i12 = new ApplicationFormItem();
    i12.setShortname("pokec");
    i12.setType(ApplicationFormItem.Type.HTML_COMMENT);
    i12.getTexts(CS).setLabel("Stiskem tlačítka 'Podat žádost o členství ve VO MetaCentrum' souhlaste s pravidly využití VO MetaCentrum.");
    i12.getTexts(EN).setLabel("By pressing the button you agree with MetaCentrum rules.");
    i12.setApplicationTypes(Arrays.asList(Application.AppType.INITIAL));
    registrarManager.addFormItem(session, applicationForm, i12);
    ApplicationFormItem i13 = new ApplicationFormItem();
    i13.setShortname("souhlasI");
    i13.setType(ApplicationFormItem.Type.SUBMIT_BUTTON);
    i13.getTexts(CS).setLabel("Podat žádost o členství ve VO MetaCentrum");
    i13.getTexts(EN).setLabel("Apply for membership in the MetaCentrum VO");
    i13.setApplicationTypes(Arrays.asList(Application.AppType.INITIAL));
    registrarManager.addFormItem(session, applicationForm, i13);
    ApplicationFormItem i13b = new ApplicationFormItem();
    i13b.setShortname("souhlasE");
    i13b.setType(ApplicationFormItem.Type.SUBMIT_BUTTON);
    i13b.getTexts(CS).setLabel("Podat žádost o prodloužení účtu");
    i13b.getTexts(EN).setLabel("Apply for account extension");
    i13b.setApplicationTypes(Arrays.asList(Application.AppType.EXTENSION));
    registrarManager.addFormItem(session, applicationForm, i13b);
    // update form not to auto aprove
    applicationForm.setAutomaticApproval(false);
    registrarManager.updateForm(session, applicationForm);
    // test returned app form
    assertEquals("Application form not same as expected", applicationForm, registrarManager.getFormForVo(vo));
    // test form items
    List<ApplicationFormItem> items = registrarManager.getFormItems(session, applicationForm);
    assertTrue("Item i0 was not returned from form", items.contains(i0));
    assertTrue("Item i0b was not returned from form", items.contains(i0b));
    assertTrue("Item i1 was not returned from form", items.contains(i1));
    assertTrue("Item i2 was not returned from form", items.contains(i2));
    assertTrue("Item i2a was not returned from form", items.contains(i2a));
    assertTrue("Item i2b was not returned from form", items.contains(i2b));
    assertTrue("Item i3 was not returned from form", items.contains(i3));
    assertTrue("Item i4 was not returned from form", items.contains(i4));
    assertTrue("Item i5 was not returned from form", items.contains(i5));
    assertTrue("Item i5b was not returned from form", items.contains(i5b));
    assertTrue("Item i5c was not returned from form", items.contains(i5c));
    assertTrue("Item i6 was not returned from form", items.contains(i6));
    assertTrue("Item i7 was not returned from form", items.contains(i7));
    assertTrue("Item i8 was not returned from form", items.contains(i8));
    assertTrue("Item i9 was not returned from form", items.contains(i9));
    assertTrue("Item i10 was not returned from form", items.contains(i10));
    assertTrue("Item i11 was not returned from form", items.contains(i11));
    assertTrue("Item i12 was not returned from form", items.contains(i12));
    assertTrue("Item i13 was not returned from form", items.contains(i13));
    assertTrue("Item i13b was not returned from form", items.contains(i13b));
    Random random = new Random();
    PerunSession applicant = perun.getPerunSession(new PerunPrincipal("rumcajs" + random.nextInt(100000) + "@raholec.cz", "http://www.raholec.cz/idp/", ExtSourcesManager.EXTSOURCE_IDP), new PerunClient());
}
Also used : ApplicationForm(cz.metacentrum.perun.registrar.model.ApplicationForm) ApplicationFormItem(cz.metacentrum.perun.registrar.model.ApplicationFormItem) PerunSession(cz.metacentrum.perun.core.api.PerunSession) PerunClient(cz.metacentrum.perun.core.api.PerunClient) PerunPrincipal(cz.metacentrum.perun.core.api.PerunPrincipal) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Transactional (org.springframework.transaction.annotation.Transactional)1415 Test (org.junit.Test)507 Query (javax.persistence.Query)166 Date (java.util.Date)121 ArrayList (java.util.ArrayList)99 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)89 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)87 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)84 OnmsNode (org.opennms.netmgt.model.OnmsNode)83 TypedQuery (javax.persistence.TypedQuery)81 Rollback (org.springframework.test.annotation.Rollback)81 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)67 HashMap (java.util.HashMap)65 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)61 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)58 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)58 DBUnitTest (org.orcid.test.DBUnitTest)57 List (java.util.List)56 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)41 User (com.arnaugarcia.uplace.domain.User)39