Example usage for java.time Month JANUARY

List of usage examples for java.time Month JANUARY

Introduction

In this page you can find the example usage for java.time Month JANUARY.

Prototype

Month JANUARY

To view the source code for java.time Month JANUARY.

Click Source Link

Document

The singleton instance for the month of January with 31 days.

Usage

From source file:fi.luontola.cqrshotel.JsonSerializationTest.java

private static Object randomValue(Class<?> type) {
    ThreadLocalRandom random = ThreadLocalRandom.current();
    if (type == UUID.class) {
        return UUID.randomUUID();
    }/*from w  w w. jav  a2  s.c  o m*/
    if (type == LocalDate.class) {
        return LocalDate.of(random.nextInt(2000, 2100),
                random.nextInt(Month.JANUARY.getValue(), Month.DECEMBER.getValue() + 1),
                random.nextInt(1, Month.FEBRUARY.minLength() + 1));
    }
    if (type == Money.class) {
        return Money.of(random.nextDouble(0, 1000), pickRandom(Monetary.getCurrencies()));
    }
    if (type == Instant.class) {
        return Instant.ofEpochMilli(random.nextLong());
    }
    if (type == String.class) {
        return RandomStringUtils.randomAlphanumeric(random.nextInt(10));
    }
    if (type == int.class) {
        return random.nextInt();
    }
    throw new IllegalArgumentException("Unsupported type: " + type);
}

From source file:org.springsource.restbucks.payment.PaymentServiceImplUnitTest.java

@Test
public void throwsOrderPaidEventOnPayment() {

    CreditCard creditCard = new CreditCard(NUMBER, "Oliver Gierke", Month.JANUARY, Year.of(2020));
    when(creditCardRepository.findByNumber(NUMBER)).thenReturn(Optional.of(creditCard));

    Order order = new Order();
    ReflectionTestUtils.setField(order, "id", 1L);

    paymentService.pay(order, NUMBER);//from  w ww . j  a  v  a 2  s  .  c o  m

    verify(publisher).publishEvent(Mockito.any((OrderPaidEvent.class)));
}

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

public boolean createLead(User user) throws IOException {

    String responseText = null;//from w ww.java2  s .  com
    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:com.bofa.sstradingreport.managementreport.TradeReportControllerTest.java

@Test
public void shouldgetTradeReports() throws Exception {
    final List<TradeReportEntity> allbikes = Arrays.asList(
            Reflect.on(TradeReportEntity.class).create().set("id", 4711).set("name", "Bike 1")
                    .set("tradeDate",
                            GregorianCalendar.from(
                                    LocalDate.of(2015, Month.JANUARY, 1).atStartOfDay(ZoneId.systemDefault())))
                    .call("getTradeReport").get(),
            Reflect.on(TradeReportEntity.class).create().set("id", 23)
                    .set("tradeDate",
                            GregorianCalendar.from(
                                    LocalDate.of(2014, Month.JANUARY, 1).atStartOfDay(ZoneId.systemDefault())))
                    .call("getTradeReport").get());
    final List<TradeReportEntity> activeBikes = Arrays.asList(allbikes.get(0));

    final TradeReportRepository repository = mock(TradeReportRepository.class);
    stub(repository.findAll(any(Sort.class))).toReturn(allbikes);
    //   stub(repository.findByDecaommissionedOnIsNull(any(Sort.class))).toReturn(activeBikes);

    final TradeReportController controller = new TradeReportController(repository);

    final MockMvc mockMvc = MockMvcBuilders.standaloneSetup(controller)
            .setControllerAdvice(new ExceptionHandlerAdvice())
            .apply(documentationConfiguration(this.restDocumentation)).build();

    mockMvc.perform(get("http://localhost:8088/sstradingreport/api/bikes").param("all", "true"))
            .andExpect(status().isOk()).andExpect(content().string(objectMapper.writeValueAsString(allbikes)))
            .andDo(document("api/bikes/get", preprocessRequest(prettyPrint()),
                    preprocessResponse(prettyPrint()),
                    requestParameters(parameterWithName("all").description(
                            "Flag, if all bikes, including decommissioned bikes, should be returned.")),
                    responseFields(fieldWithPath("[]").description("An array of bikes"),
                            fieldWithPath("[].id").description("The unique Id of the bike"),
                            fieldWithPath("[].name").description("The name of the bike"),
                            fieldWithPath("[].tradeDate").description("The date the bike was bought"))));

    mockMvc.perform(get("http://biking.michael-simons.eu/api/bikes")).andExpect(status().isOk())
            .andExpect(content().string(objectMapper.writeValueAsString(activeBikes)));

    Mockito.verify(repository).findAll(Mockito.any(Sort.class));
    //   Mockito.verify(repository).findByDecommissionedOnIsNull(Mockito.any(Sort.class));
    verifyNoMoreInteractions(repository);
}

From source file:se.backede.jeconomix.forms.report.SingleTransactionReport.java

private DefaultCategoryDataset createDataset(TransactionReportDto reports) {

    String lineTitle = "Kronor";

    Map<Month, BigDecimal> sums = new HashMap<>();

    List<Month> monthList = new LinkedList<>(Arrays.asList(Month.values()));

    monthList.forEach((month) -> {/*from   w ww.  j av a2  s. c o m*/
        sums.put(month, BigDecimal.valueOf(0));
    });

    reports.getTransctions().forEach((TransactionDto transaction) -> {
        monthList.stream().filter((month) -> (transaction.getBudgetMonth().equals(month)))
                .forEachOrdered((month) -> {
                    BigDecimal currentSum = sums.get(month);
                    if (transaction.getSum() != null) {
                        double abs = Math.abs(transaction.getSum().doubleValue());
                        BigDecimal newSum = currentSum.add(BigDecimal.valueOf(abs));
                        sums.put(month, newSum);
                    }
                });
    });

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.addValue(sums.get(Month.JANUARY), lineTitle, "Jan");
    dataset.addValue(sums.get(Month.FEBRUARY), lineTitle, "Feb");
    dataset.addValue(sums.get(Month.MARCH), lineTitle, "Mar");
    dataset.addValue(sums.get(Month.APRIL), lineTitle, "Apr");
    dataset.addValue(sums.get(Month.MAY), lineTitle, "May");
    dataset.addValue(sums.get(Month.JUNE), lineTitle, "Jun");
    dataset.addValue(sums.get(Month.JULY), lineTitle, "Jul");
    dataset.addValue(sums.get(Month.AUGUST), lineTitle, "Aug");
    dataset.addValue(sums.get(Month.SEPTEMBER), lineTitle, "Sep");
    dataset.addValue(sums.get(Month.OCTOBER), lineTitle, "Oct");
    dataset.addValue(sums.get(Month.NOVEMBER), lineTitle, "Nov");
    dataset.addValue(sums.get(Month.DECEMBER), lineTitle, "Dec");
    return dataset;
}

From source file:org.openlmis.fulfillment.service.OrderCsvHelperTest.java

private ProcessingPeriodDto createPeriod() {
    ProcessingPeriodDto period = new ProcessingPeriodDto();
    period.setName("periodName");
    period.setStartDate(LocalDate.of(2016, Month.JANUARY, 1));

    return period;
}

From source file:com.gnadenheimer.mg3.utils.Utils.java

public static LocalDate inicioPeriodoFiscal() {
    return LocalDate.of(App.periodoFiscal, Month.JANUARY, 1);
}

From source file:org.openlmis.fulfillment.web.ProofOfDeliveryControllerIntegrationTest.java

/**
 * Prepare the test environment./*  w  ww  .jav a2  s. c o 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>());
}