List of usage examples for java.time ZonedDateTime now
public static ZonedDateTime now()
From source file:org.apache.james.jmap.model.MailboxMessageTest.java
@Test(expected = IllegalStateException.class) public void buildShouldThrowWhenPreviewIsNull() { Message.builder().id(MessageId.of("user|box|1")).blobId(BlobId.of("blobId")).threadId("threadId") .mailboxIds(ImmutableList.of()).headers(ImmutableMap.of()).subject("subject").size(123) .date(ZonedDateTime.now()).build(); }
From source file:alfio.manager.CheckInManager.java
public TicketAndCheckInResult checkIn(int eventId, String ticketIdentifier, Optional<String> ticketCode, String user) {/*from ww w .j a va 2 s . co m*/ TicketAndCheckInResult descriptor = extractStatus(eventId, ticketRepository.findByUUIDForUpdate(ticketIdentifier), ticketIdentifier, ticketCode); if (descriptor.getResult().getStatus() == OK_READY_TO_BE_CHECKED_IN) { checkIn(ticketIdentifier); scanAuditRepository.insert(ticketIdentifier, eventId, ZonedDateTime.now(), user, SUCCESS, ScanAudit.Operation.SCAN); auditingRepository.insert(descriptor.getTicket().getTicketsReservationId(), userRepository.findIdByUserName(user).orElse(null), eventId, Audit.EventType.CHECK_IN, new Date(), Audit.EntityType.TICKET, Integer.toString(descriptor.getTicket().getId())); return new TicketAndCheckInResult(descriptor.getTicket(), new DefaultCheckInResult(SUCCESS, "success")); } return descriptor; }
From source file:it.tidalwave.northernwind.frontend.filesystem.hg.MercurialFileSystemProvider.java
/******************************************************************************************************************* * * Checks whether there are incoming changes. Changes are detected when there's a new tag whose name follows the * pattern 'published-<version>'. Changes are pulled in the alternate repository, then repositories are swapped, at * last the alternateRepository is updated too. * ******************************************************************************************************************/ public void checkForUpdates() { try {//from ww w . j a va 2 s .com final Tag newTag = findNewTag(); log.info(">>>> new tag: {}", newTag); alternateRepository.updateTo(newTag); swapRepositories(); messageBus.publish(new ResourceFileSystemChangedEvent(this, ZonedDateTime.now())); alternateRepository.pull(); alternateRepository.updateTo(newTag); } catch (NotFoundException e) { log.info(">>>> no changes"); } catch (Exception e) { log.warn(">>>> error when checking for updates in " + alternateRepository.getWorkArea(), e); } }
From source file:org.apache.james.jmap.utils.FilterToSearchQueryTest.java
@Test public void filterConditionShouldMapWhenAfter() { ZonedDateTime after = ZonedDateTime.now(); SearchQuery expectedSearchQuery = new SearchQuery(); expectedSearchQuery//from ww w . j a v a2 s. c om .andCriteria(SearchQuery.internalDateAfter(Date.from(after.toInstant()), DateResolution.Second)); SearchQuery searchQuery = new FilterToSearchQuery().convert(FilterCondition.builder().after(after).build()); assertThat(searchQuery).isEqualTo(expectedSearchQuery); }
From source file:com.sumzerotrading.eod.trading.strategy.ReportGeneratorTest.java
@Test public void testOrderEvent_FirstRoundTrip() throws Exception { TradeReferenceLine tradeReferenceLine = new TradeReferenceLine(); tradeReferenceLine.correlationId = "123"; order.setCurrentStatus(OrderStatus.Status.FILLED); OrderEvent orderEvent = new OrderEvent(order, new OrderStatus(OrderStatus.Status.NEW, "", "", new StockTicker("QQQ"), ZonedDateTime.now())); doReturn(tradeReferenceLine).when(reportGenerator).getTradeReferenceLine(any(String.class)); doNothing().when(reportGenerator).savePartial(any(String.class), any(RoundTrip.class)); assertTrue(reportGenerator.roundTripMap.isEmpty()); reportGenerator.orderEvent(orderEvent); verify(reportGenerator).savePartial(eq("123"), any(RoundTrip.class)); verify(reportGenerator, never()).writeRoundTripToFile(any(RoundTrip.class)); assertEquals(1, reportGenerator.roundTripMap.size()); }
From source file:it.tidalwave.northernwind.frontend.filesystem.hg.MercurialFileSystemProviderTest.java
/******************************************************************************************************************* * ******************************************************************************************************************/ @Test(dependsOnMethods = "must_properly_initialize") public void checkForUpdates_must_update_and_fire_event_when_there_are_updates() throws Exception { // given//from w w w .j a va 2 s .com updateWorkAreaTo(underTest.getCurrentWorkArea(), new Tag("published-0.8")); final int previousSwapCounter = underTest.swapCounter; prepareSourceRepository(Option.UPDATE_TO_PUBLISHED_0_9); final ZonedDateTime now = ZonedDateTime.now(); // DateTimeUtils.setCurrentMillisFixed(now.getMillis()); // when underTest.checkForUpdates(); // then assertInvariantPostConditions(); assertThat(underTest.getCurrentTag().getName(), is("published-0.9")); assertThat(underTest.swapCounter, is(previousSwapCounter + 1)); verify(messageBus).publish(is(argThat(fileSystemChangedEvent().withResourceFileSystemProvider(underTest)))); }
From source file:org.apache.james.jmap.model.MailboxMessageTest.java
@Test(expected = IllegalStateException.class) public void buildShouldThrowWhenPreviewIsEmpty() { Message.builder().id(MessageId.of("user|box|1")).blobId(BlobId.of("blobId")).threadId("threadId") .mailboxIds(ImmutableList.of()).headers(ImmutableMap.of()).subject("subject").size(123) .date(ZonedDateTime.now()).preview("").build(); }
From source file:com.sumzerotrading.reporting.csv.ReportGeneratorTest.java
@Test public void testOrderEvent_NotStrategy() throws Exception { order.setCurrentStatus(OrderStatus.Status.FILLED); OrderEvent orderEvent = new OrderEvent(order, new OrderStatus(OrderStatus.Status.NEW, "", "", new StockTicker("QQQ"), ZonedDateTime.now())); TradeReferenceLine tradeReferenceLine = new TradeReferenceLine(); tradeReferenceLine.setCorrelationId("123").setStrategy("Other Strategy").setDirection(LONG).setSide(EXIT); order.setCurrentStatus(OrderStatus.Status.FILLED); doReturn(tradeReferenceLine).when(reportGenerator).getTradeReferenceLine(any(String.class)); reportGenerator.orderEvent(orderEvent); verify(reportGenerator, never()).writeRoundTripToFile(any(PairTradeRoundTrip.class)); verify(reportGenerator, never()).savePartial(Matchers.anyString(), anyObject()); }
From source file:org.openlmis.fulfillment.web.ProofOfDeliveryControllerIntegrationTest.java
/** * Prepare the test environment.//from w w w . ja v a 2 s . co m */ @Before public void setUp() { this.setUpBootstrapData(); OrderableDto product = new OrderableDto(); product.setId(UUID.randomUUID()); FacilityDto facility = new FacilityDto(); facility.setId(UUID.randomUUID()); facility.setCode("facilityCode"); facility.setName("facilityName"); facility.setDescription("facilityDescription"); facility.setActive(true); facility.setEnabled(true); SupervisoryNodeDto supervisoryNode = new SupervisoryNodeDto(); supervisoryNode.setId(UUID.randomUUID()); supervisoryNode.setCode("NodeCode"); supervisoryNode.setName("NodeName"); supervisoryNode.setFacility(facility); ProgramDto program = new ProgramDto(); program.setId(UUID.randomUUID()); program.setCode("programCode"); ProcessingPeriodDto period = new ProcessingPeriodDto(); period.setId(UUID.randomUUID()); period.setProcessingSchedule(new ProcessingScheduleDto()); period.setName("periodName"); period.setStartDate(LocalDate.of(2015, Month.JANUARY, 1)); period.setEndDate(LocalDate.of(2015, Month.DECEMBER, 31)); Order order = new Order(); order.setId(UUID.randomUUID()); order.setExternalId(UUID.randomUUID()); order.setProgramId(program.getId()); order.setFacilityId(facility.getId()); order.setProcessingPeriodId(period.getId()); order.setEmergency(false); order.setStatus(OrderStatus.SHIPPED); order.setCreatedDate(ZonedDateTime.now()); order.setCreatedById(UUID.randomUUID()); order.setOrderCode("O1"); order.setProgramId(program.getId()); order.setQuotedCost(new BigDecimal(100)); order.setSupplyingFacilityId(facility.getId()); order.setRequestingFacilityId(facility.getId()); order.setReceivingFacilityId(facility.getId()); given(orderRepository.findOne(order.getId())).willReturn(order); given(orderRepository.exists(order.getId())).willReturn(true); OrderLineItem orderLineItem = new OrderLineItem(); orderLineItem.setId(UUID.randomUUID()); orderLineItem.setOrderableId(product.getId()); orderLineItem.setOrderedQuantity(100L); orderLineItem.setFilledQuantity(100L); orderLineItem.setApprovedQuantity(0L); orderLineItem.setPacksToShip(100L); proofOfDeliveryLineItem.setId(UUID.randomUUID()); proofOfDeliveryLineItem.setOrderLineItem(orderLineItem); proofOfDeliveryLineItem.setQuantityShipped(100L); proofOfDeliveryLineItem.setQuantityReturned(100L); proofOfDeliveryLineItem.setQuantityReceived(100L); proofOfDeliveryLineItem.setReplacedProductCode("replaced product code"); proofOfDeliveryLineItem.setNotes("Notes"); proofOfDelivery.setId(UUID.randomUUID()); proofOfDelivery.setOrder(order); proofOfDelivery.setDeliveredBy("delivered by"); proofOfDelivery.setReceivedBy("received by"); proofOfDelivery.setReceivedDate(ZonedDateTime.now()); proofOfDelivery.setProofOfDeliveryLineItems(new ArrayList<>()); proofOfDelivery.getProofOfDeliveryLineItems().add(proofOfDeliveryLineItem); proofOfDeliveryDto = ProofOfDeliveryDto.newInstance(proofOfDelivery, exporter); given(proofOfDeliveryRepository.findOne(proofOfDelivery.getId())).willReturn(proofOfDelivery); given(proofOfDeliveryRepository.findOne(proofOfDeliveryId)).willReturn(null); given(proofOfDeliveryRepository.exists(proofOfDelivery.getId())).willReturn(true); given(proofOfDeliveryRepository.save(any(ProofOfDelivery.class))) .willAnswer(new SaveAnswer<ProofOfDelivery>()); }
From source file:org.apache.james.jmap.model.MailboxMessageTest.java
@Test public void buildShouldWorkWhenMandatoryFieldsArePresent() { ZonedDateTime currentDate = ZonedDateTime.now(); Message expected = new Message(MessageId.of("user|box|1"), BlobId.of("blobId"), "threadId", ImmutableList.of("mailboxId"), Optional.empty(), false, false, false, false, false, ImmutableMap.of("key", "value"), Optional.empty(), ImmutableList.of(), ImmutableList.of(), ImmutableList.of(), ImmutableList.of(), "subject", currentDate, 123, "preview", Optional.empty(), Optional.empty(), ImmutableList.of(), ImmutableMap.of()); Message tested = Message.builder().id(MessageId.of("user|box|1")).blobId(BlobId.of("blobId")) .threadId("threadId").mailboxIds(ImmutableList.of("mailboxId")) .headers(ImmutableMap.of("key", "value")).subject("subject").size(123).date(currentDate) .preview("preview").build(); assertThat(tested).isEqualToComparingFieldByField(expected); }