Search in sources :

Example 1 with PersonElement

use of com.hack23.cia.model.external.riksdagen.personlista.impl.PersonElement in project cia by Hack23.

the class RiksdagenPersonApiImplITest method getPersonMixedTest.

/**
 * Gets the person mixed test.
 *
 * @return the person mixed test
 * @throws Exception
 *             the exception
 */
@Test
public void getPersonMixedTest() throws Exception {
    final PersonContainerElement personList = riksdagenApi.getPersonList();
    assertNotNull(personList);
    assertTrue(personList.getPerson().size() >= 1291);
    final PersonElement person = personList.getPerson().get(0);
    assertNotNull("Missing id : " + person.getLastName(), person.getId());
    final PersonData personDetail = riksdagenApi.getPerson(person.getId());
    assertNotNull("Missing personDetail : " + person.getLastName(), personDetail);
    assertNotNull("Missing personDetail.person : " + person.getLastName(), personDetail.getLastName());
    assertNotNull("Missing personDetail.person.id : " + person.getLastName(), personDetail.getId());
    assertNotNull(personDetail.getFirstName());
    assertNotNull(personDetail.getLastName());
}
Also used : PersonElement(com.hack23.cia.model.external.riksdagen.personlista.impl.PersonElement) PersonData(com.hack23.cia.model.external.riksdagen.person.impl.PersonData) PersonContainerElement(com.hack23.cia.model.external.riksdagen.personlista.impl.PersonContainerElement) Test(org.junit.Test)

Example 2 with PersonElement

use of com.hack23.cia.model.external.riksdagen.personlista.impl.PersonElement in project cia by Hack23.

the class RiksdagenPersonsWorkGeneratorImpl method generateWorkOrders.

@Override
public void generateWorkOrders() {
    try {
        final List<PersonElement> personList = riksdagenApi.getPersonList().getPerson();
        final Map<String, String> currentSaved = getImportService().getPersonMap();
        for (final PersonElement personElement : personList) {
            if (!currentSaved.containsKey(personElement.getId())) {
                LOGGER.info("Send Load Order:{}", personElement.getPersonUrlXml());
                getJmsSender().send(personElementWorkdestination, personElement);
                currentSaved.put(personElement.getId(), personElement.getId());
            }
        }
        for (final String personId : readMissingPersonList()) {
            if (!currentSaved.containsKey(personId)) {
                LOGGER.info("Send Load Order:{}{}", "https://data.riksdagen.se/person/", personId);
                getJmsSender().send(personElementWorkdestination, new PersonElement().withId(personId));
            }
        }
    } catch (final DataFailureException exception) {
        LOGGER.warn("Problem during generate work orders", exception);
    }
}
Also used : PersonElement(com.hack23.cia.model.external.riksdagen.personlista.impl.PersonElement) DataFailureException(com.hack23.cia.service.external.riksdagen.api.DataFailureException)

Example 3 with PersonElement

use of com.hack23.cia.model.external.riksdagen.personlista.impl.PersonElement in project cia by Hack23.

the class RiksdagenPersonApiImplITest method getPersonTest.

/**
 * Gets the person test.
 *
 * @return the person test
 * @throws Exception
 *             the exception
 */
@Test
public void getPersonTest() throws Exception {
    final PersonData personElement = riksdagenApi.getPerson("0389619060499");
    assertNotNull(personElement);
    assertEquals("Bohman", personElement.getLastName());
}
Also used : PersonData(com.hack23.cia.model.external.riksdagen.person.impl.PersonData) Test(org.junit.Test)

Example 4 with PersonElement

use of com.hack23.cia.model.external.riksdagen.personlista.impl.PersonElement in project cia by Hack23.

the class RiksdagenPersonElementWorkConsumerImplITest method onMessageSuccessTest.

/**
 * On message success test.
 *
 * @throws JMSException
 *             the JMS exception
 */
@Test
@Transactional
public void onMessageSuccessTest() throws JMSException {
    final ObjectMessage message = mock(ObjectMessage.class);
    when(message.getObject()).thenReturn(new PersonElement().withId("0542160909628"));
    messsageListener.onMessage(message);
    verify(message, atLeastOnce()).getObject();
}
Also used : PersonElement(com.hack23.cia.model.external.riksdagen.personlista.impl.PersonElement) ObjectMessage(javax.jms.ObjectMessage) Test(org.junit.Test) AbstractServiceComponentAgentFunctionalIntegrationTest(com.hack23.cia.service.component.agent.impl.AbstractServiceComponentAgentFunctionalIntegrationTest) Transactional(javax.transaction.Transactional)

Aggregations

PersonElement (com.hack23.cia.model.external.riksdagen.personlista.impl.PersonElement)3 Test (org.junit.Test)3 PersonData (com.hack23.cia.model.external.riksdagen.person.impl.PersonData)2 PersonContainerElement (com.hack23.cia.model.external.riksdagen.personlista.impl.PersonContainerElement)1 AbstractServiceComponentAgentFunctionalIntegrationTest (com.hack23.cia.service.component.agent.impl.AbstractServiceComponentAgentFunctionalIntegrationTest)1 DataFailureException (com.hack23.cia.service.external.riksdagen.api.DataFailureException)1 ObjectMessage (javax.jms.ObjectMessage)1 Transactional (javax.transaction.Transactional)1