Example usage for java.time LocalDateTime of

List of usage examples for java.time LocalDateTime of

Introduction

In this page you can find the example usage for java.time LocalDateTime of.

Prototype

public static LocalDateTime of(int year, int month, int dayOfMonth, int hour, int minute) 

Source Link

Document

Obtains an instance of LocalDateTime from year, month, day, hour and minute, setting the second and nanosecond to zero.

Usage

From source file:eu.off.db.entity.MemberTest.java

@Test
public void BuildFullMember() {

    LocalDateTime dateTime = LocalDateTime.of(1978, Month.APRIL, 4, 0, 0);
    Date birthday = Date.from(dateTime.atZone(ZoneId.systemDefault()).toInstant());

    Member aMember = new MemberBuilder(LAST_NAME, FIRST_NAME, STREET, ZIP_CODE, PLACE, COUNTRY, birthday,
            GENDER, NATIONALITY).email(EMAIL).phone(PHONE).portablePhone(PORTABLE_PHONE).memberSince(birthday)
                    .licenseSince(birthday).build();

    assertThat(aMember.getEmail().equals(EMAIL));
    assertThat(aMember.getPhone().equals(PHONE));
    assertThat(aMember.getPortablePhone().equals(PORTABLE_PHONE));
    assertThat(aMember.getMemberSince().equals(birthday));
    assertThat(aMember.getLicenseSince().equals(birthday));

}

From source file:com.jubination.io.chatbot.backend.service.core.LMSUpdater.java

public boolean createLead(User user) throws IOException {

    String responseText = null;/* w  w w .j a va  2s.  c o m*/
    Document doc = null;
    CloseableHttpResponse response = null;
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder;
    InputSource is;
    try {
        //requesting exotel to initiate call
        CloseableHttpClient httpclient = HttpClients.createDefault();
        HttpPost httpPost = new HttpPost("http://188.166.253.79/save_enquiry");
        List<NameValuePair> formparams = new ArrayList<>();

        formparams.add(new BasicNameValuePair("form_data[0][email_id]", user.getEmail()));
        formparams.add(new BasicNameValuePair("form_data[0][full_name]", user.getName()));
        formparams.add(new BasicNameValuePair("form_data[0][contact_no]", user.getPhone()));
        formparams.add(new BasicNameValuePair("form_data[0][city]", user.getCountry()));
        formparams.add(new BasicNameValuePair("form_data[0][ip]", "na"));
        if (user.getFbId() != null) {
            formparams.add(new BasicNameValuePair("form_data[0][campaign_id]", "162"));
            formparams.add(new BasicNameValuePair("form_data[0][source]", "fb-chatbot"));
        } else {
            formparams.add(new BasicNameValuePair("form_data[0][campaign_id]", "161"));
            formparams.add(new BasicNameValuePair("form_data[0][source]", "web-chatbot"));
        }
        formparams.add(new BasicNameValuePair("form_data[0][step_2]", "no"));
        formparams.add(new BasicNameValuePair("form_data[0][step_2_created_at]",
                new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())));
        LocalDateTime backdate = LocalDateTime.of(2013, Month.JANUARY, 1, 0, 0);
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        formparams.add(new BasicNameValuePair("form_data[0][step_2_inform_at]", backdate.format(formatter)));
        formparams.add(new BasicNameValuePair("form_data[0][chat_id]", user.getSesId()));
        for (Entry<String, Boolean> trigger : user.getTriggers().entrySet()) {
            formparams.add(new BasicNameValuePair("form_data[0][chat_" + trigger.getKey() + "]",
                    trigger.getValue().toString()));
        }

        UrlEncodedFormEntity uEntity = new UrlEncodedFormEntity(formparams, Consts.UTF_8);
        httpPost.setEntity(uEntity);
        response = httpclient.execute(httpPost);
        HttpEntity entity = response.getEntity();

        responseText = EntityUtils.toString(entity, "UTF-8");
    } catch (IOException | ParseException | DOMException e) {
        e.printStackTrace();
    } finally {
        if (response != null) {
            response.close();
        }
    }
    System.out.println(responseText);
    return responseText != null;
}

From source file:fi.vrk.xroad.catalog.lister.JaxbCatalogServiceTest.java

@Test
public void testGetAll() throws Exception {
    XMLGregorianCalendar calendar20150505 = jaxbConverter
            .toXmlGregorianCalendar(LocalDateTime.of(2015, 5, 5, 0, 0));
    XMLGregorianCalendar calendar20140505 = jaxbConverter
            .toXmlGregorianCalendar(LocalDateTime.of(2014, 5, 5, 0, 0));
    Iterable<fi.vrk.xroad.xroad_catalog_lister.Member> members = service.getAllMembers(calendar20150505);
    assertEquals(2, Iterables.size(members));
    assertEquals(new HashSet<String>(Arrays.asList("2", "3")), new HashSet<String>(getMemberCodes(members)));
    assertMember2Contents(members);//w ww  .  j av a 2 s  .co  m

    members = service.getAllMembers(calendar20140505);
    assertEquals(3, Iterables.size(members));
    assertEquals(new HashSet<String>(Arrays.asList("1", "2", "3")),
            new HashSet<String>(getMemberCodes(members)));
    assertMember2Contents(members);

    members = service.getAllMembers(null);
    assertEquals(3, Iterables.size(members));
    assertEquals(new HashSet<String>(Arrays.asList("1", "2", "3")),
            new HashSet<String>(getMemberCodes(members)));
    assertMember2Contents(members);
}

From source file:fi.vrk.xroad.catalog.persistence.CatalogServiceTest.java

@Test
public void testEntityTreesFetchedCorrectly() throws InterruptedException {
    assertEntityTreeFetchedCorrectly(catalogService.getAllMembers());
    assertEntityTreeFetchedCorrectly(catalogService.getActiveMembers());
    LocalDateTime modifiedSince1800 = LocalDateTime.of(1800, 1, 1, 0, 0);
    assertEntityTreeFetchedCorrectly(catalogService.getAllMembers(modifiedSince1800));
    assertEntityTreeFetchedCorrectly(catalogService.getActiveMembers(modifiedSince1800));
}

From source file:com.romeikat.datamessie.core.base.query.DocumentFilterSettingsQueryTest.java

@Override
protected Operation initDb() {
    final SourceType sourceType1 = new SourceType(1, "SourceType1");
    final SourceType sourceType2 = new SourceType(2, "SourceType2");
    final Source source11 = new Source(11, "Source11", "http://www.source11.de/", true);
    final Source source12 = new Source(12, "Source12", "http://www.source12.de/", false);
    final Source source21 = new Source(21, "Source21", "http://www.source21.de/", true);
    final Source source22 = new Source(22, "Source22", "http://www.source22.de/", false);
    final Source2SourceType source2SourceType111 = new Source2SourceType(11, 1);
    final Source2SourceType source2SourceType211 = new Source2SourceType(21, 1);
    final Source2SourceType source2SourceType122 = new Source2SourceType(12, 2);
    final Source2SourceType source2SourceType222 = new Source2SourceType(22, 2);
    final Project project1 = new Project(1, "Project1", false, false);
    final Project project2 = new Project(2, "Project2", false, false);
    final Project2Source project2Source111 = new Project2Source(1, 11);
    final Project2Source project2Source112 = new Project2Source(1, 12);
    final Project2Source project2Source221 = new Project2Source(2, 21);
    final Project2Source project2Source222 = new Project2Source(2, 22);
    final Crawling crawling11 = new Crawling(11, project1.getId());
    final Crawling crawling12 = new Crawling(12, project1.getId());
    final Crawling crawling21 = new Crawling(21, project2.getId());
    final Crawling crawling22 = new Crawling(22, project2.getId());
    final Document document11 = new Document(11, crawling11.getId(), source11.getId())
            .setPublished(LocalDateTime.of(2015, 9, 30, 12, 0))
            .setDownloaded(LocalDateTime.of(2015, 9, 30, 12, 0)).setState(DocumentProcessingState.DOWNLOADED);
    final Document document12 = new Document(12, crawling12.getId(), source11.getId())
            .setPublished(LocalDateTime.of(2015, 9, 30, 13, 0))
            .setDownloaded(LocalDateTime.of(2015, 9, 30, 13, 0))
            .setState(DocumentProcessingState.DOWNLOAD_ERROR);
    final Document document13 = new Document(13, crawling11.getId(), source12.getId())
            .setPublished(LocalDateTime.of(2015, 9, 30, 14, 0))
            .setDownloaded(LocalDateTime.of(2015, 9, 30, 14, 0)).setState(DocumentProcessingState.DOWNLOADED);
    final Document document14 = new Document(14, crawling12.getId(), source12.getId())
            .setPublished(LocalDateTime.of(2015, 9, 30, 15, 0))
            .setDownloaded(LocalDateTime.of(2015, 9, 30, 15, 0))
            .setState(DocumentProcessingState.DOWNLOAD_ERROR);
    final Document document21 = new Document(21, crawling21.getId(), source21.getId())
            .setPublished(LocalDateTime.of(2015, 10, 1, 12, 0))
            .setDownloaded(LocalDateTime.of(2015, 10, 1, 12, 0)).setState(DocumentProcessingState.DOWNLOADED);
    final Document document22 = new Document(22, crawling22.getId(), source21.getId())
            .setPublished(LocalDateTime.of(2015, 10, 1, 13, 0))
            .setDownloaded(LocalDateTime.of(2015, 10, 1, 13, 0))
            .setState(DocumentProcessingState.DOWNLOAD_ERROR);
    final Document document23 = new Document(23, crawling21.getId(), source22.getId())
            .setPublished(LocalDateTime.of(2015, 10, 1, 14, 0))
            .setDownloaded(LocalDateTime.of(2015, 10, 1, 14, 0)).setState(DocumentProcessingState.DOWNLOADED);
    final Document document24 = new Document(24, crawling22.getId(), source22.getId())
            .setPublished(LocalDateTime.of(2015, 10, 1, 15, 0))
            .setDownloaded(LocalDateTime.of(2015, 10, 1, 15, 0))
            .setState(DocumentProcessingState.DOWNLOAD_ERROR);
    final CleanedContent cleanedContent11 = new CleanedContent(document11.getId(), "Foo is good");
    final CleanedContent cleanedContent13 = new CleanedContent(document13.getId(), "Bar is better");
    final CleanedContent cleanedContent21 = new CleanedContent(document21.getId(), "Foo rocks");
    final CleanedContent cleanedContent23 = new CleanedContent(document23.getId(), "Bar hurts");

    return sequenceOf(CommonOperations.DELETE_ALL_FOR_DATAMESSIE,
            // Source types 1, 2
            insertIntoSourceType(sourceType1), insertIntoSourceType(sourceType2),

            // Sources 11, 12, 21, 22
            insertIntoSource(source11), insertIntoSource(source12), insertIntoSource(source21),
            insertIntoSource(source22),/*w  w w  .  j av a  2  s  . c  o  m*/
            // Sources 11, 21 -> Source type 1
            insertIntoSource2SourceType(source2SourceType111),
            insertIntoSource2SourceType(source2SourceType211),
            // Sources 12, 22 -> Source type 2
            insertIntoSource2SourceType(source2SourceType122),
            insertIntoSource2SourceType(source2SourceType222),

            // Project 1
            insertIntoProject(project1),
            // Project 1 -> Sources 11, 12
            insertIntoProject2Source(project2Source111), insertIntoProject2Source(project2Source112),
            // Crawlings 11, 12
            insertIntoCrawling(crawling11), insertIntoCrawling(crawling12),
            // Documents 11, 12, 13, 14
            insertIntoDocument(document11), insertIntoDocument(document12), insertIntoDocument(document13),
            insertIntoDocument(document14),
            // Contents 11, 13
            insertIntoCleanedContent(cleanedContent11), insertIntoCleanedContent(cleanedContent13),

            // Project 2
            insertIntoProject(project2),
            // Project 2 -> Sources 21, 22
            insertIntoProject2Source(project2Source221), insertIntoProject2Source(project2Source222),
            // Crawlings 21, 22
            insertIntoCrawling(crawling21), insertIntoCrawling(crawling22),
            // Documents 21, 22, 23, 24
            insertIntoDocument(document21), insertIntoDocument(document22), insertIntoDocument(document23),
            insertIntoDocument(document24),
            // Contents 21, 23
            insertIntoCleanedContent(cleanedContent21), insertIntoCleanedContent(cleanedContent23));
}

From source file:com.ccserver.digital.service.CreditCardApplicationExtractionServiceTest.java

@Test
public void ExportExcelAdminTest() throws IOException {
    List<CreditCardApplication> applicationList = new ArrayList<>();
    CreditCardApplication creditCardApplication = new CreditCardApplication();
    creditCardApplication.setFirstName("First Name");
    creditCardApplication.setLastName("Last Name");
    creditCardApplication.setPassportNumber("121213");
    creditCardApplication.setEmail("you@you");
    creditCardApplication.setBusinessStartDate(LocalDateTime.now());
    creditCardApplication.setDateOfIssue(null);
    Phone mobile = new Phone();
    mobile.setCountryCode("+84");
    mobile.setPhoneNumber("98599999999");
    creditCardApplication.setMobile(mobile);
    //creditCardApplication.setLosApplicationId("123GTP");
    creditCardApplication.setSaleAgentId("45678");
    creditCardApplication.setStatus(Status.SubmittedApp);
    creditCardApplication.setSubmittedAppTime(LocalDateTime.of(1992, 1, 10, 0, 0));
    creditCardApplication.setSubmittedDocTime(LocalDateTime.now());
    creditCardApplication.setVerification(LocalDateTime.now());
    creditCardApplication.setCardShipped(LocalDateTime.now());
    creditCardApplication.setCardDelivered(LocalDateTime.now());
    creditCardApplication.setId(1L);//from   w ww. java2s . c  om
    applicationList.add(creditCardApplication);
    Date from = new Date();
    Date to = new Date();
    Mockito.when(repository.getApplicationsByTime(from, to)).thenReturn(applicationList);

    byte[] result = ccAppExtractionService.exportExcelAdmin(from, to);
    Assert.assertNotNull(result);
}

From source file:msi.gama.util.GamaDate.java

public GamaDate(final IScope scope, final int second, final int minute, final int hour, final int day,
        final int month, final int year) {
    this(scope, LocalDateTime.of(year, month, day, hour, minute));
}

From source file:com.ikanow.aleph2.search_service.elasticsearch.utils.TestElasticsearchHadoopUtils.java

@Test
public void test_getTimedIndexes() {
    final LinkedHashMultimap<String, String> test_in = LinkedHashMultimap.create();
    test_in.put("test_time_sliced_index__4633d78cd58b_2015.04.01", "test");
    test_in.put("test_time_sliced_index__4633d78cd58b_2015.06.01", "test");
    test_in.put("r__test_time_sliced_index__4633d78cd58b_2015.06.03", "test");
    test_in.put("r__test_time_sliced_index__4633d78cd58b", "test");

    // min + max/*  w w  w  . j  av  a 2  s .  co m*/
    {
        final Date now = Date
                .from(LocalDateTime.of(2015, 6, 12, 2, 0).atZone(ZoneOffset.systemDefault()).toInstant());

        AnalyticThreadJobInputConfigBean test = BeanTemplateUtils.build(AnalyticThreadJobInputConfigBean.class)
                .with(AnalyticThreadJobInputConfigBean::time_min, "12 days")
                .with(AnalyticThreadJobInputConfigBean::time_max, "8 days").done().get();

        AnalyticThreadJobInputBean input = BeanTemplateUtils.build(AnalyticThreadJobInputBean.class)
                .with(AnalyticThreadJobInputBean::config, test).done().get();

        final Optional<Stream<String>> res = ElasticsearchHadoopUtils.getTimedIndexes(input, test_in, now);

        assertEquals(
                Arrays.asList("test_time_sliced_index__4633d78cd58b_2015.06.01",
                        "r__test_time_sliced_index__4633d78cd58b_2015.06.03"),
                res.map(s -> s.collect(Collectors.toList())).get());
    }
    // neither
    {
        AnalyticThreadJobInputConfigBean test = BeanTemplateUtils.build(AnalyticThreadJobInputConfigBean.class)
                .done().get();

        AnalyticThreadJobInputBean input = BeanTemplateUtils.build(AnalyticThreadJobInputBean.class)
                .with(AnalyticThreadJobInputBean::config, test).done().get();

        final Optional<Stream<String>> res = ElasticsearchHadoopUtils.getTimedIndexes(input, test_in,
                new Date());

        assertEquals(Optional.empty(), res);
    }

}

From source file:de.steilerdev.myVerein.server.controller.init.InitController.java

License:asdf

/**
 * This function is clearing the current database and creates a new set of test data. This function is called by POSTing the URI '/'
 * @return In general it should just return okay. No error checking is done!
 *///from   ww  w  . j  a  va2 s  .  c om
@RequestMapping(value = "database", method = RequestMethod.POST)
public ResponseEntity<String> createDatabaseExample() {
    logger.debug("Deleting old database and reloading database example.");
    resetDatabase();

    User user1 = new User("Frank", "Steiler", "frank@steiler.eu", "asdf");
    user1.setBirthday(LocalDate.of(1994, 6, 28));
    user1.setActiveSince(LocalDate.of(2000, 1, 1));
    user1.setIban("DE46500700100927353010");
    user1.setBic("BYLADEM1001");
    user1.setCity("Stuttgart");
    user1.setZipCode("70190");
    user1.setStreetNumber("27");
    user1.setStreet("Metzstrae");
    user1.setCountry("Germany");
    user1.setGender(User.Gender.MALE);
    User user2 = new User("John", "Doe", "john@doe.com", "asdf");
    user2.setActiveSince(LocalDate.of(1999, 1, 1));
    user2.setPassiveSince(LocalDate.of(2000, 6, 1));
    User user3 = new User("Peter", "Enis", "peter@enis.com", "asdf");
    User user4 = new User("Luke", "Skywalker", "luke@skywalker.com", "asdf");
    user4.setGender(User.Gender.MALE);
    User user5 = new User("Marty", "McFly", "marty@mcfly.com", "asdf");
    User user6 = new User("Tammo", "Schwindt", "tammo@tammon.de", "asdf");

    userRepository.save(user1);
    userRepository.save(user2);
    userRepository.save(user3);
    userRepository.save(user4);
    userRepository.save(user5);
    userRepository.save(user6);

    Division div1 = new Division("myVerein", null, user1, null);
    Division div2 = new Division("Rugby", null, user2, div1);
    Division div3 = new Division("Soccer", null, null, div1);
    Division div4 = new Division("Rugby - 1st team", null, user2, div2);
    Division div5 = new Division("Rugby - 2nd team", null, user3, div2);

    divisionRepository.save(div1);
    divisionRepository.save(div2);
    divisionRepository.save(div3);
    divisionRepository.save(div4);
    divisionRepository.save(div5);

    int thisMonth = LocalDateTime.now().getMonthValue();
    int thisYear = LocalDateTime.now().getYear();

    Event event1 = new Event();
    event1.setStartDateTime(LocalDateTime.of(thisYear, thisMonth, 20, 13, 0));
    event1.setEndDateTime(LocalDateTime.of(thisYear, thisMonth, 20, 14, 0));
    event1.setName("Super Event 1");
    event1.setLocation("DHBW Stuttgart");
    event1.setLocationLat(48.7735272);
    event1.setLocationLng(9.171102399999995);
    event1.setDescription("Super event at awesome location with great people");
    event1.addDivision(div2);
    event1.setEventAdmin(user1);
    event1.updateMultiDate();
    event1.setLastChanged(LocalDateTime.now());

    Event event2 = new Event();
    event2.setStartDateTime(LocalDateTime.of(thisYear, thisMonth, 20, 13, 0));
    event2.setEndDateTime(LocalDateTime.of(thisYear, thisMonth, 21, 13, 0));
    event2.setName("Super Event 2");
    event2.addDivision(div3);
    event2.setEventAdmin(user4);
    event2.updateMultiDate();
    event2.setLastChanged(LocalDateTime.now());

    Event event3 = new Event();
    event3.setStartDateTime(LocalDateTime.of(thisYear, thisMonth, 21, 13, 0));
    event3.setEndDateTime(LocalDateTime.of(thisYear, thisMonth, 21, 13, 5));
    event3.setName("Super Event 3");
    event3.addDivision(div1);
    event3.setEventAdmin(user1);
    event3.updateMultiDate();
    event3.setLastChanged(LocalDateTime.now());

    Event event4 = new Event();
    event4.setStartDateTime(LocalDateTime.of(thisYear, thisMonth, 11, 13, 0));
    event4.setEndDateTime(LocalDateTime.of(thisYear, thisMonth, 15, 13, 5));
    event4.setName("Super Event 4");
    event4.addDivision(div1);
    event4.setEventAdmin(user2);
    event4.updateMultiDate();
    event4.setLastChanged(LocalDateTime.now());

    eventRepository.save(event1);
    eventRepository.save(event2);
    eventRepository.save(event3);
    eventRepository.save(event4);

    user1.replaceDivisions(divisionRepository, eventRepository, div1);
    user2.replaceDivisions(divisionRepository, eventRepository, div2, div4);
    user3.replaceDivisions(divisionRepository, eventRepository, div2);
    user4.replaceDivisions(divisionRepository, eventRepository, div3);
    user5.replaceDivisions(divisionRepository, eventRepository, div2, div4);

    userRepository.save(user1);
    userRepository.save(user2);
    userRepository.save(user3);
    userRepository.save(user4);
    userRepository.save(user5);

    Message message1 = new Message("Hello world", user1, divisionRepository.findById(div1.getId()));
    Message message2 = new Message("Hello world, too", user2, divisionRepository.findById(div1.getId()));
    messageRepository.save(message1);
    messageRepository.save(message2);

    Settings systemSettings = new Settings();
    systemSettings.setClubName("myVerein");
    List<String> customUserFields = new ArrayList<>();
    customUserFields.add("Membership number");
    systemSettings.setCustomUserFields(customUserFields);
    settingsRepository.save(systemSettings);

    return new ResponseEntity<>("Successfully reset database to example", HttpStatus.OK);
}

From source file:alfio.controller.ReservationFlowIntegrationTest.java

/**
 * Test a complete offline payment flow.
 * Will not check in detail...//from  w  w w.  j  a  v  a 2 s . c om
 */
@Test
public void reservationFlowTest() throws Exception {

    String eventName = event.getShortName();

    assertTrue(checkInManager.findAllFullTicketInfo(event.getId()).isEmpty());

    List<EventStatistic> eventStatistic = eventStatisticsManager.getAllEventsWithStatistics(user);
    assertEquals(1, eventStatistic.size());
    assertTrue(eventStatisticsManager
            .getTicketSoldStatistics(event.getId(), new Date(0), DateUtils.addDays(new Date(), 1)).isEmpty());
    EventWithAdditionalInfo eventWithAdditionalInfo = eventStatisticsManager
            .getEventWithAdditionalInfo(event.getShortName(), user);
    assertEquals(0, eventWithAdditionalInfo.getNotSoldTickets());
    assertEquals(0, eventWithAdditionalInfo.getSoldTickets());
    assertEquals(20, eventWithAdditionalInfo.getAvailableSeats());

    eventManager.toggleActiveFlag(event.getId(), user, true);
    // list events
    String eventList = eventController.listEvents(new BindingAwareModelMap(), Locale.ENGLISH);
    if (eventManager.getPublishedEvents().size() == 1) {
        Assert.assertTrue(eventList.startsWith("redirect:/"));
    } else {
        assertEquals("/event/event-list", eventList);
    }
    //

    // show event
    String showEvent = eventController.showEvent(eventName, new BindingAwareModelMap(),
            new MockHttpServletRequest(), Locale.ENGLISH);
    assertEquals("/event/show-event", showEvent);
    //

    // check calendar
    checkCalendar(eventName);
    //

    String redirectResult = reserveTicket(eventName);
    String redirectStart = "redirect:/event/" + eventName + "/reservation/";
    // check reservation success
    Assert.assertTrue(redirectResult.startsWith(redirectStart));
    Assert.assertTrue(redirectResult.endsWith("/book"));
    //

    String reservationIdentifier = redirectResult.substring(redirectStart.length()).replace("/book", "");

    // check that the payment page is shown
    String reservationPage = reservationController.showPaymentPage(eventName, reservationIdentifier, null, null,
            null, null, null, null, null, null, null, null, null, new BindingAwareModelMap(), Locale.ENGLISH);
    assertEquals("/event/reservation-page", reservationPage);
    //

    // pay offline
    String successPage = payOffline(eventName, reservationIdentifier);
    assertEquals("redirect:/event/" + eventName + "/reservation/" + reservationIdentifier + "/success",
            successPage);
    //

    //go to success page, payment is still pending
    String confirmationPage = reservationController.showConfirmationPage(eventName, reservationIdentifier,
            false, false, new BindingAwareModelMap(), Locale.ENGLISH, new MockHttpServletRequest());
    Assert.assertTrue(confirmationPage.endsWith("/waitingPayment"));

    assertEquals("/event/reservation-waiting-for-payment", reservationController.showWaitingPaymentPage(
            eventName, reservationIdentifier, new BindingAwareModelMap(), Locale.ENGLISH));

    //
    validatePayment(eventName, reservationIdentifier);
    //

    Assert.assertTrue(reservationController.showWaitingPaymentPage(eventName, reservationIdentifier,
            new BindingAwareModelMap(), Locale.ENGLISH).endsWith("/success"));

    //
    TicketDecorator ticketDecorator = checkReservationComplete(eventName, reservationIdentifier);
    //

    String ticketIdentifier = ticketDecorator.getUuid();

    //ticket is still not assigned, will redirect
    Assert.assertTrue(ticketController
            .showTicket(eventName, ticketIdentifier, false, Locale.ENGLISH, new BindingAwareModelMap())
            .startsWith("redirect:/event/"));
    Assert.assertTrue(ticketController
            .showTicketForUpdate(eventName, ticketIdentifier, new BindingAwareModelMap(), Locale.ENGLISH)
            .startsWith("redirect:/event/"));
    //

    String fname1 = "Test";
    String lname1 = "McTest";

    //assign ticket to person
    assignTicket(eventName, reservationIdentifier, ticketIdentifier, fname1, lname1);

    assertEquals(1, checkInManager.findAllFullTicketInfo(event.getId()).size());

    assertEquals("/event/update-ticket", ticketController.showTicketForUpdate(eventName, ticketIdentifier,
            new BindingAwareModelMap(), Locale.ENGLISH));

    //
    assertEquals("/event/show-ticket", ticketController.showTicket(eventName, ticketIdentifier, false,
            Locale.ENGLISH, new BindingAwareModelMap()));
    //
    checkCSV(eventName, ticketIdentifier, fname1 + " " + lname1);

    // use api to update
    UpdateTicketOwnerForm updateTicketOwnerForm = new UpdateTicketOwnerForm();
    updateTicketOwnerForm.setFirstName("Test");
    updateTicketOwnerForm.setLastName("Testson");
    updateTicketOwnerForm.setEmail("testmctest@test.com");
    updateTicketOwnerForm.setUserLanguage("en");
    reservationApiController.assignTicketToPerson(eventName, ticketIdentifier, true, updateTicketOwnerForm,
            new BeanPropertyBindingResult(updateTicketOwnerForm, "updateTicketForm"),
            new MockHttpServletRequest(), new BindingAwareModelMap(), null);
    checkCSV(eventName, ticketIdentifier, "Test Testson");
    //

    //update
    String fname2 = "Test";
    String lname2 = "OTest";
    assignTicket(eventName, reservationIdentifier, ticketIdentifier, fname2, lname2);
    checkCSV(eventName, ticketIdentifier, fname2 + " " + lname2);

    //lock ticket
    Principal principal = Mockito.mock(Principal.class);
    Mockito.when(principal.getName()).thenReturn(user);
    eventApiController.toggleTicketLocking(eventName, ticketDecorator.getCategoryId(), ticketDecorator.getId(),
            principal);

    assignTicket(eventName, reservationIdentifier, ticketIdentifier, fname1, fname2);
    checkCSV(eventName, ticketIdentifier, fname2 + " " + lname2);

    //ticket has changed, update
    ticketDecorator = checkReservationComplete(eventName, reservationIdentifier);

    // check stats after selling one ticket
    assertFalse(eventStatisticsManager
            .getTicketSoldStatistics(event.getId(), new Date(0), DateUtils.addDays(new Date(), 2)).isEmpty());
    EventWithAdditionalInfo eventWithAdditionalInfo2 = eventStatisticsManager
            .getEventWithAdditionalInfo(event.getShortName(), user);
    assertEquals(0, eventWithAdditionalInfo2.getNotSoldTickets());
    assertEquals(1, eventWithAdditionalInfo2.getSoldTickets());
    assertEquals(20, eventWithAdditionalInfo2.getAvailableSeats());
    assertEquals(0, eventWithAdditionalInfo2.getCheckedInTickets());

    //--- check in sequence
    String ticketCode = ticketDecorator.ticketCode(event.getPrivateKey());
    TicketAndCheckInResult ticketAndCheckInResult = checkInApiController.findTicketWithUUID(event.getId(),
            ticketIdentifier, ticketCode);
    assertEquals(CheckInStatus.OK_READY_TO_BE_CHECKED_IN, ticketAndCheckInResult.getResult().getStatus());
    CheckInApiController.TicketCode tc = new CheckInApiController.TicketCode();
    tc.setCode(ticketCode);
    assertEquals(CheckInStatus.SUCCESS, checkInApiController
            .checkIn(event.getId(), ticketIdentifier, tc, new TestingAuthenticationToken("ciccio", "ciccio"))
            .getResult().getStatus());
    List<ScanAudit> audits = scanAuditRepository.findAllForEvent(event.getId());
    assertFalse(audits.isEmpty());
    assertTrue(audits.stream().anyMatch(sa -> sa.getTicketUuid().equals(ticketIdentifier)));

    TicketAndCheckInResult ticketAndCheckInResultOk = checkInApiController.findTicketWithUUID(event.getId(),
            ticketIdentifier, ticketCode);
    assertEquals(CheckInStatus.ALREADY_CHECK_IN, ticketAndCheckInResultOk.getResult().getStatus());

    // check stats after check in one ticket
    assertFalse(eventStatisticsManager
            .getTicketSoldStatistics(event.getId(), new Date(0), DateUtils.addDays(new Date(), 1)).isEmpty());
    EventWithAdditionalInfo eventWithAdditionalInfo3 = eventStatisticsManager
            .getEventWithAdditionalInfo(event.getShortName(), user);
    assertEquals(0, eventWithAdditionalInfo3.getNotSoldTickets());
    assertEquals(0, eventWithAdditionalInfo3.getSoldTickets());
    assertEquals(20, eventWithAdditionalInfo3.getAvailableSeats());
    assertEquals(1, eventWithAdditionalInfo3.getCheckedInTickets());

    //test revert check in
    assertTrue(checkInApiController.revertCheckIn(event.getId(), ticketIdentifier, principal));
    assertFalse(checkInApiController.revertCheckIn(event.getId(), ticketIdentifier, principal));
    TicketAndCheckInResult ticketAndCheckInResult2 = checkInApiController.findTicketWithUUID(event.getId(),
            ticketIdentifier, ticketCode);
    assertEquals(CheckInStatus.OK_READY_TO_BE_CHECKED_IN, ticketAndCheckInResult2.getResult().getStatus());

    UsersApiController.UserWithPasswordAndQRCode sponsorUser = usersApiController
            .insertUser(new UserModification(null, event.getOrganizationId(), "SPONSOR", "sponsor", "first",
                    "last", "email@email.com"), "http://localhost:8080", principal);
    Principal sponsorPrincipal = Mockito.mock(Principal.class);
    Mockito.when(sponsorPrincipal.getName()).thenReturn(sponsorUser.getUsername());

    // check failures
    assertEquals(CheckInStatus.EVENT_NOT_FOUND,
            attendeeApiController.scanBadge(
                    new AttendeeApiController.SponsorScanRequest("not-existing-event", "not-existing-ticket"),
                    sponsorPrincipal).getBody().getResult().getStatus());
    assertEquals(CheckInStatus.TICKET_NOT_FOUND,
            attendeeApiController
                    .scanBadge(new AttendeeApiController.SponsorScanRequest(eventName, "not-existing-ticket"),
                            sponsorPrincipal)
                    .getBody().getResult().getStatus());
    assertEquals(CheckInStatus.INVALID_TICKET_STATE,
            attendeeApiController
                    .scanBadge(new AttendeeApiController.SponsorScanRequest(eventName, ticketIdentifier),
                            sponsorPrincipal)
                    .getBody().getResult().getStatus());
    //

    // check stats after revert check in one ticket
    assertFalse(eventStatisticsManager
            .getTicketSoldStatistics(event.getId(), new Date(0), DateUtils.addDays(new Date(), 1)).isEmpty());
    EventWithAdditionalInfo eventWithAdditionalInfo4 = eventStatisticsManager
            .getEventWithAdditionalInfo(event.getShortName(), user);
    assertEquals(0, eventWithAdditionalInfo4.getNotSoldTickets());
    assertEquals(1, eventWithAdditionalInfo4.getSoldTickets());
    assertEquals(20, eventWithAdditionalInfo4.getAvailableSeats());
    assertEquals(0, eventWithAdditionalInfo4.getCheckedInTickets());

    CheckInApiController.TicketCode tc2 = new CheckInApiController.TicketCode();
    tc2.setCode(ticketCode);
    TicketAndCheckInResult ticketAndcheckInResult = checkInApiController.checkIn(event.getId(),
            ticketIdentifier, tc2, new TestingAuthenticationToken("ciccio", "ciccio"));
    assertEquals(CheckInStatus.SUCCESS, ticketAndcheckInResult.getResult().getStatus());
    //

    //
    List<Integer> offlineIdentifiers = checkInApiController.getOfflineIdentifiers(event.getShortName(), 0L,
            new MockHttpServletResponse(), principal);
    assertTrue(offlineIdentifiers.isEmpty());
    configurationRepository.insertEventLevel(event.getOrganizationId(), event.getId(),
            ConfigurationKeys.OFFLINE_CHECKIN_ENABLED.name(), "true", null);
    configurationRepository.insert(ConfigurationKeys.ALFIO_PI_INTEGRATION_ENABLED.name(), "true", null);
    offlineIdentifiers = checkInApiController.getOfflineIdentifiers(event.getShortName(), 0L,
            new MockHttpServletResponse(), principal);
    assertFalse(offlineIdentifiers.isEmpty());
    Map<String, String> payload = checkInApiController.getOfflineEncryptedInfo(event.getShortName(),
            Collections.emptyList(), offlineIdentifiers, principal);
    assertEquals(1, payload.size());
    Ticket ticket = ticketAndcheckInResult.getTicket();
    String ticketKey = ticket.hmacTicketInfo(event.getPrivateKey());
    String hashedTicketKey = DigestUtils.sha256Hex(ticketKey);
    String encJson = payload.get(hashedTicketKey);
    assertNotNull(encJson);
    String ticketPayload = CheckInManager.decrypt(ticket.getUuid() + "/" + ticketKey, encJson);
    Map<String, String> jsonPayload = Json.fromJson(ticketPayload, new TypeReference<Map<String, String>>() {
    });
    assertNotNull(jsonPayload);
    assertEquals(8, jsonPayload.size());
    assertEquals("Test", jsonPayload.get("firstName"));
    assertEquals("OTest", jsonPayload.get("lastName"));
    assertEquals("Test OTest", jsonPayload.get("fullName"));
    assertEquals(ticket.getUuid(), jsonPayload.get("uuid"));
    assertEquals("testmctest@test.com", jsonPayload.get("email"));
    assertEquals("CHECKED_IN", jsonPayload.get("status"));
    String categoryName = ticketCategoryRepository.findByEventId(event.getId()).stream().findFirst()
            .orElseThrow(IllegalStateException::new).getName();
    assertEquals(categoryName, jsonPayload.get("category"));
    //

    // check register sponsor scan success flow
    assertTrue(attendeeApiController.getScannedBadges(event.getShortName(),
            EventUtil.JSON_DATETIME_FORMATTER.format(LocalDateTime.of(1970, 1, 1, 0, 0)), sponsorPrincipal)
            .getBody().isEmpty());
    assertEquals(CheckInStatus.SUCCESS,
            attendeeApiController
                    .scanBadge(new AttendeeApiController.SponsorScanRequest(eventName, ticket.getUuid()),
                            sponsorPrincipal)
                    .getBody().getResult().getStatus());
    assertEquals(1,
            attendeeApiController.getScannedBadges(event.getShortName(),
                    EventUtil.JSON_DATETIME_FORMATTER.format(LocalDateTime.of(1970, 1, 1, 0, 0)),
                    sponsorPrincipal).getBody().size());
    //

    eventManager.deleteEvent(event.getId(), principal.getName());

}