Java Code Examples for org.joda.time.LocalDate

The following examples show how to use org.joda.time.LocalDate. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Test
@Transactional
public void shouldInsertPetIntoDatabaseAndGenerateId() {
    Owner owner6 = this.clinicService.findOwnerById(6);
    int found = owner6.getPets().size();

    Pet pet = new Pet();
    pet.setName("bowser");
    Collection<PetType> types = this.clinicService.findPetTypes();
    pet.setType(EntityUtils.getById(types, PetType.class, 2));
    pet.setBirthDate(new LocalDate());
    owner6.addPet(pet);
    assertThat(owner6.getPets().size()).isEqualTo(found + 1);

    this.clinicService.savePet(pet);
    this.clinicService.saveOwner(owner6);

    owner6 = this.clinicService.findOwnerById(6);
    assertThat(owner6.getPets().size()).isEqualTo(found + 1);
    // checks that id has been generated
    assertThat(pet.getId()).isNotNull();
}
 
Example 2
Source Project: estatio   Source File: TurnoverAggregationService_Test.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void isComparableToDate_works() throws Exception {

    //given
    TurnoverAggregationService service = new TurnoverAggregationService();
    final LocalDate aggregationDate = new LocalDate(2019, 2, 1);

    // when, then
    assertThat(service.isComparableToDate(aggregationDate, 2, 2, false, false)).isTrue();
    assertThat(service.isComparableToDate(aggregationDate, 3, 2, false, false)).isTrue();
    assertThat(service.isComparableToDate(aggregationDate, 1, 2, false, false)).isFalse();
    assertThat(service.isComparableToDate(aggregationDate, 2, 1, false, false)).isFalse();
    assertThat(service.isComparableToDate(aggregationDate, 2, 2, true, false)).isFalse();
    assertThat(service.isComparableToDate(aggregationDate, 2, 2, false, true)).isFalse();

    assertThat(service.isComparableToDate(aggregationDate, 0, 2, false, true)).isFalse();

    assertThat(service.isComparableToDate(aggregationDate, null, 2, false, true)).isFalse();
    assertThat(service.isComparableToDate(aggregationDate, 0, null, false, true)).isFalse();
}
 
Example 3
@Test
public void findByTurnoverReportingConfig_works() throws Exception {

    final TurnoverReportingConfig config = TurnoverReportingConfig_enum.OxfTopModel001GbPrelim
            .findUsing(serviceRegistry2);
    final LocalDate date = new LocalDate(2019, 1, 1);
    final LocalDate date2 = new LocalDate(2019, 2, 1);
    final Currency euro = Currency_enum.EUR.findUsing(serviceRegistry2);

    // when
    turnoverAggregationRepository
            .findOrCreate(config, date, euro);
    turnoverAggregationRepository
            .findOrCreate(config, date2, euro);

    // then
    assertThat(turnoverAggregationRepository.findByTurnoverReportingConfig(config)).hasSize(2);

}
 
Example 4
@Override
public LocalDate getPresentationRequestDate() {
    if (super.getPresentationRequestDate() != null) {
        return super.getPresentationRequestDate();
    }

    if (!getIndividualProgramProcess().getStudyPlan().isExempted()) {
        if (getIndividualProgramProcess().getRegistration().isConcluded()) {
            return getIndividualProgramProcess().getRegistration().getConclusionDate().toLocalDate();
        }
    }

    if (getPresentationDate() != null) {
        return getPresentationDate().minusMonths(1);
    }

    return getIndividualProgramProcess().getWhenStartedStudies();
}
 
Example 5
Source Project: estatio   Source File: Order_2_IntegTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setupData() {

    runFixtureScript(new FixtureScript() {
        @Override
        protected void execute(final FixtureScript.ExecutionContext executionContext) {

            // taken from the DocumentTypesAndTemplatesSeedService (not run in integ tests by default)
            final LocalDate templateDate = ld(2012,1,1);

            executionContext.executeChildren(this,
                    new DocumentTypesAndTemplatesForCapexFixture(templateDate),
                    new IncomingChargesFraXlsxFixture());

            executionContext.executeChildren(this,
                    Order_enum.fakeOrder2Pdf,
                    Person_enum.JonathanIncomingInvoiceManagerGb);
        }
    });
    order = Order_enum.fakeOrder2Pdf.findUsing(serviceRegistry);

    ((Organisation) order.getSeller()).setChamberOfCommerceCode("Code");
}
 
Example 6
Source Project: estatio   Source File: FixedAssetRole_Test.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected List<List<FixedAssetRole>> orderedTuples() {
    return listOf(
            listOf(
                    newFixedAssetRole(null, null, null, null),
                    newFixedAssetRole(asset1, null, null, null),
                    newFixedAssetRole(asset1, null, null, null),
                    newFixedAssetRole(asset2, null, null, null))
            ,listOf(
                    newFixedAssetRole(asset1, new LocalDate(2012,4,2), null, null),
                    newFixedAssetRole(asset1, new LocalDate(2012,3,1), null, null),
                    newFixedAssetRole(asset1, new LocalDate(2012,3,1), null, null),
                    newFixedAssetRole(asset1, null, null, null))
            ,listOf(
                    newFixedAssetRole(asset1, new LocalDate(2012,4,2), null, null),
                    newFixedAssetRole(asset1, new LocalDate(2012,4,2), FixedAssetRoleTypeEnum.ASSET_MANAGER, null),
                    newFixedAssetRole(asset1, new LocalDate(2012,4,2), FixedAssetRoleTypeEnum.ASSET_MANAGER, null),
                    newFixedAssetRole(asset1, new LocalDate(2012,4,2), FixedAssetRoleTypeEnum.PROPERTY_CONTACT, null))
            ,listOf(
                    newFixedAssetRole(asset1, new LocalDate(2012,4,2), FixedAssetRoleTypeEnum.ASSET_MANAGER, null),
                    newFixedAssetRole(asset1, new LocalDate(2012,4,2), FixedAssetRoleTypeEnum.ASSET_MANAGER, party1),
                    newFixedAssetRole(asset1, new LocalDate(2012,4,2), FixedAssetRoleTypeEnum.ASSET_MANAGER, party1),
                    newFixedAssetRole(asset1, new LocalDate(2012,4,2), FixedAssetRoleTypeEnum.ASSET_MANAGER, party2))
    );
}
 
Example 7
Source Project: estatio   Source File: DocFragments_for_Invoicing_Test.java    License: Apache License 2.0 6 votes vote down vote up
@Ignore // in EST-1197
@Test
public void adjustment_and_chargeGroupOfS_and_dueDate_after_startDate() throws Exception {

    // given

    final LocalDate itemDueDate = new LocalDate(2017, 3, 1);

    item.setAdjustment(true);
    chargeGroup.setReference("S");
    item.setDueDate(itemDueDate);
    item.setStartDate(itemDueDate.minusDays(1));

    item.setEffectiveStartDate(new LocalDate(2017, 4, 1));
    item.setEffectiveEndDate(new LocalDate(2017, 10, 15));

    // when
    final String rendered = freeMarkerService.render(templateName, templateText, vm);

    // then
    Assertions.assertThat(rendered)
            .isEqualTo("Conguaglio: Charge description dal 01-04-2017 al 15-10-2017");
}
 
Example 8
Source Project: estatio   Source File: InvoiceForLeaseRepository.java    License: Apache License 2.0 6 votes vote down vote up
public InvoiceForLease findOrCreateMatchingInvoice(
        final ApplicationTenancy applicationTenancy,
        final Party seller,
        final Party buyer,
        final PaymentMethod paymentMethod,
        final Lease lease,
        final InvoiceStatus invoiceStatus,
        final LocalDate dueDate,
        final String interactionId) {
    final List<InvoiceForLease> invoices = findMatchingInvoices(
            seller, buyer, paymentMethod, lease, invoiceStatus, dueDate);
    if (invoices == null || invoices.size() == 0) {
        return newInvoice(applicationTenancy, seller, buyer, paymentMethod, settingsService.systemCurrency(), dueDate, lease, interactionId);
    }
    return invoices.get(0);
}
 
Example 9
/**
 * Returns the number of days between two dates.
 */
@Function("DAYS")
@FunctionParameters({
	@FunctionParameter("startDate"),
	@FunctionParameter("endDate")})
public Integer DAYS(Object startDate, Object endDate){
	Date startDateObj = convertDateObject(startDate);
	if(startDateObj==null) {
		logCannotConvertToDate();
		return null;
	}
	Date endDateObj = convertDateObject(endDate);
	if(endDateObj==null){
		logCannotConvertToDate();
		return null;
	}
	else{
		LocalDate dt1=new LocalDate(startDateObj);
		LocalDate dt2=new LocalDate(endDateObj);
		return Days.daysBetween(dt1, dt2).getDays();
	}
}
 
Example 10
Source Project: estatio   Source File: DocumentTemplate.java    License: Apache License 2.0 6 votes vote down vote up
private DocumentTemplate(
        final DocumentType type,
        final LocalDate date,
        final String atPath,
        final String fileSuffix,
        final boolean previewOnly,
        final String nameText) {
    super(type, atPath);

    this.typeCopy = type;
    this.atPathCopy = atPath;
    this.date = date;
    this.fileSuffix = stripLeadingDotAndLowerCase(fileSuffix);
    this.previewOnly = previewOnly;
    this.nameText = nameText;
}
 
Example 11
@Test
public void find_by_reported_date_works() throws Exception {
    // given
    final IncomingInvoice invoice1 = createIncomingInvoice();
    final IncomingInvoiceItem item1OnInv1 = incomingInvoiceItemRepository
            .addItem(invoice1, IncomingInvoiceType.CAPEX, null, null, null, null, null, null, null, null, null,
                    null, null);
    final IncomingInvoiceItem item2OnInv1 = incomingInvoiceItemRepository
            .addItem(invoice1, IncomingInvoiceType.CAPEX, null, null, null, null, null, null, null, null, null,
                    null, null);
    final IncomingInvoiceItem item3OnInv1 = incomingInvoiceItemRepository
            .addItem(invoice1, IncomingInvoiceType.CAPEX, null, null, null, null, null, null, null, null, null,
                    null, null);

    final IncomingInvoice invoice2 = createIncomingInvoice();
    final IncomingInvoiceItem item1OnInv2 = incomingInvoiceItemRepository
            .addItem(invoice2, IncomingInvoiceType.CAPEX, null, null, null, null, null, null, null, null, null,
                    null, null);

    // when, then
    assertThat(incomingInvoiceQueryHelperRepo.findByInvoiceItemReportedDate(null)).hasSize(4);

    // and when
    final LocalDate reportedDate = new LocalDate(2020, 1, 1);
    item1OnInv1.setReportedDate(reportedDate);

    // then
    assertThat(incomingInvoiceQueryHelperRepo.findByInvoiceItemReportedDate(reportedDate)).hasSize(1);
    assertThat(incomingInvoiceQueryHelperRepo.findByInvoiceItemReportedDate(null)).hasSize(3);

}
 
Example 12
Source Project: activiti6-boot2   Source File: VariablesTest.java    License: Apache License 2.0 5 votes vote down vote up
private Map<String, Object> generateVariables() {
  Map<String, Object> vars = new HashMap<String, Object>();

  // 10 Strings
  for (int i = 0; i < 10; i++) {
    vars.put("stringVar" + i, "stringVarValue-" + i);
  }

  // 10 integers
  for (int i = 0; i < 10; i++) {
    vars.put("intVar" + i, i * 100);
  }

  // 10 dates
  for (int i = 0; i < 10; i++) {
    vars.put("dateVar" + i, new Date());
  }
  
  // 10 joda local dates
  for (int i = 0; i < 10; i++) {
    vars.put("localdateVar" + i, new LocalDate());
  }
  
  // 10 joda local dates
  for (int i = 0; i < 10; i++) {
    vars.put("datetimeVar" + i, new DateTime());
  }

  // 10 booleans
  for (int i = 0; i < 10; i++) {
    vars.put("booleanValue" + i, (i % 2 == 0));
  }

  // 10 Serializables
  for (int i = 0; i < 10; i++) {
    vars.put("serializableValue" + i, new TestSerializableVariable(i));
  }
  return vars;
}
 
Example 13
Source Project: Simple-Dilbert   Source File: DilbertFragmentAdapter.java    License: Apache License 2.0 5 votes vote down vote up
DilbertFragmentAdapter(FragmentManager fm, DilbertPreferences preferences) {
    super(fm);
    this.countCache = Days.daysBetween(
            DilbertPreferences.getFirstStripDate(),
            LocalDate.now()).getDays() + 1;
    this.preferences = preferences;
}
 
Example 14
Source Project: prayer-times-android   Source File: ImsakiyeFragment.java    License: Apache License 2.0 5 votes vote down vote up
public void setTimes(Times t) {
    mTimes = t;
    if (mAdapter != null) {
        mAdapter.times = mTimes;
        mAdapter.notifyDataSetChanged();
        mAdapter.daysInMonth = ((LocalDate) mAdapter.getItem(1)).dayOfMonth().getMaximumValue();

    }
}
 
Example 15
Source Project: estatio   Source File: EventRepository.java    License: Apache License 2.0 5 votes vote down vote up
@Programmatic
public Event newEvent(final LocalDate date, final EventSource eventSource, final String calendarName) {
    final Event event = newTransientInstance(Event.class);
    event.setDate(date);
    event.setCalendarName(calendarName);
    event.setSource(eventSource);
    persistIfNotAlready(event);

    return event;
}
 
Example 16
Source Project: estatio   Source File: LeaseTermForTurnoverRent_Test.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void useGivenEndDate() {
    // given
    LeaseTerm term = new LeaseTermForTurnoverRent();
    term.setStartDate(new LocalDate(2014,1,1));
    term.setEndDate(term.getStartDate().plusDays(1));
    term.setFrequency(LeaseTermFrequency.YEARLY);
    //when
    term.doInitialize();
    //then
    assertThat(term.getEndDate()).isEqualTo(term.getStartDate().plusDays(1));
}
 
Example 17
Source Project: estatio   Source File: IndexValueRepository.java    License: Apache License 2.0 5 votes vote down vote up
private IndexValue create(
        final IndexBase indexBase,
        final LocalDate startDate,
        final BigDecimal value) {
    final IndexValue indexValue;
    indexValue = newTransientInstance();
    indexValue.setStartDate(startDate);
    indexValue.setIndexBase(indexBase);
    indexValue.setValue(value);
    persistIfNotAlready(indexValue);
    return indexValue;
}
 
Example 18
Source Project: estatio   Source File: DocumentTemplate.java    License: Apache License 2.0 5 votes vote down vote up
public DocumentTemplate(
        final DocumentType type,
        final LocalDate date,
        final String atPath,
        final String fileSuffix,
        final boolean previewOnly,
        final Blob blob,
        final String subjectText) {
    this(type, date, atPath, fileSuffix, previewOnly, subjectText);
    modifyBlob(blob);
}
 
Example 19
Source Project: estatio   Source File: BudgetRepository.java    License: Apache License 2.0 5 votes vote down vote up
@Programmatic
public Budget findByPropertyAndDate(Property property, LocalDate date){
    List<Budget> allBudgetsOfProperty = allMatches("findByProperty", "property", property);
    for (Budget budget : allBudgetsOfProperty) {
        LocalDateInterval budgetInterval = new LocalDateInterval(budget.getStartDate(), budget.getEndDate());
        if (budgetInterval.contains(date)) {
            return budget;
        }
    }
    return null;
}
 
Example 20
Source Project: estatio   Source File: InvoiceAttributesVM_Test.java    License: Apache License 2.0 5 votes vote down vote up
static void addItemFor(
        final InvoiceForLease invoiceForLease,
        final LocalDate start,
        final LocalDate end) {
    InvoiceItemForLease ii = new InvoiceItemForLease();
    ii.setStartDate(start);
    ii.setEndDate(end);
    invoiceForLease.getItems().add(ii);
}
 
Example 21
protected void testIt(final StudentLine studentLine) {
    String institutionCode = studentLine.getInstitutionCode();
    String institutionName = studentLine.getInstitutionName();
    String candidacyNumber = studentLine.getCandidacyNumber();
    String studentNumberForPrint = studentLine.getStudentNumberForPrint();
    String studentName = studentLine.getStudentName();
    String documentTypeName = studentLine.getDocumentTypeName();
    String documentNumber = studentLine.getDocumentNumber();
    String degreeCode = studentLine.getDegreeCode();
    String degreeName = studentLine.getDegreeName();
    String degreeTypeName = studentLine.getDegreeTypeName();
    Integer countNumberOfDegreeChanges = studentLine.getCountNumberOfDegreeChanges();
    Boolean hasMadeDegreeChange = studentLine.getHasMadeDegreeChange();
    LocalDate firstEnrolmentOnCurrentExecutionYear = studentLine.getFirstEnrolmentOnCurrentExecutionYear();
    String regime = studentLine.getRegime();
    String firstRegistrationExecutionYear = studentLine.getFirstRegistrationExecutionYear();
    Integer countNumberOfEnrolmentsYearsSinceRegistrationStart =
            studentLine.getCountNumberOfEnrolmentsYearsSinceRegistrationStart();
    Integer countNumberOfEnrolmentsYearsInIntegralRegime = studentLine.getCountNumberOfEnrolmentsYearsInIntegralRegime();
    Integer numberOfDegreeCurricularYears = studentLine.getNumberOfDegreeCurricularYears();
    Integer curricularYearOneYearAgo = studentLine.getCurricularYearOneYearAgo();
    BigDecimal numberOfEnrolledEctsOneYearAgo = studentLine.getNumberOfEnrolledEctsOneYearAgo();
    BigDecimal numberOfApprovedEctsOneYearAgo = studentLine.getNumberOfApprovedEctsOneYearAgo();
    Integer curricularYearInCurrentYear = studentLine.getCurricularYearInCurrentYear();
    Double numberOfEnrolledECTS = studentLine.getNumberOfEnrolledECTS();
    double numberOfDoneECTS = studentLine.getNumberOfDoneECTS();
    Money gratuityAmount = studentLine.getGratuityAmount();
    Integer numberOfMonthsExecutionYear = studentLine.getNumberOfMonthsExecutionYear();
    String firstMonthOfPayment = studentLine.getFirstMonthOfPayment();
    Boolean ownerOfCETQualification = studentLine.getOwnerOfCETQualification();
    boolean degreeQualificationOwner = studentLine.isDegreeQualificationOwner();
    boolean masterQualificationOwner = studentLine.isMasterQualificationOwner();
    boolean phdQualificationOwner = studentLine.isPhdQualificationOwner();
    boolean ownerOfCollegeQualification = studentLine.isOwnerOfCollegeQualification();
    String observations = studentLine.getObservations();
    String lastEnrolmentExecutionYear = studentLine.getLastEnrolledExecutionYear();
    String nif = studentLine.getNif();

}
 
Example 22
Source Project: dalesbred   Source File: JodaTypeConversions.java    License: MIT License 5 votes vote down vote up
public static void register(@NotNull TypeConversionRegistry typeConversionRegistry) {
    typeConversionRegistry.registerConversions(Timestamp.class, DateTime.class, DateTime::new, v -> new Timestamp(v.getMillis()));

    typeConversionRegistry.registerConversionFromDatabase(java.util.Date.class, LocalDate.class, LocalDate::fromDateFields);
    typeConversionRegistry.registerConversionFromDatabase(Time.class, LocalTime.class, LocalTime::new);
    typeConversionRegistry.registerConversionFromDatabase(String.class, DateTimeZone.class, DateTimeZone::forID);

    typeConversionRegistry.registerConversionToDatabase(LocalDate.class, value -> new Date(value.toDateTimeAtStartOfDay().getMillis()));
    typeConversionRegistry.registerConversionToDatabase(LocalTime.class, value -> new Time(value.toDateTimeToday(DateTimeZone.getDefault()).getMillis()));
    typeConversionRegistry.registerConversionToDatabase(DateTimeZone.class, DateTimeZone::getID);
}
 
Example 23
Source Project: estatio   Source File: LeaseAmendment.java    License: Apache License 2.0 5 votes vote down vote up
@Programmatic
public LocalDate getEffectiveEndDate(){
    final Optional<LocalDate> max = Lists.newArrayList(getItems()).stream()
            .map(ai -> ai.getEndDate())
            .max(LocalDate::compareTo);
    if (max.isPresent()) {
        return max.get();
    } else {
        // only when there are no items
        return null;
    }
}
 
Example 24
Source Project: estatio   Source File: BudgetRepository_IntegTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void wrongBudgetDates() {

    // given
    final Property property = Property_enum.OxfGb.findUsing(serviceRegistry);

    // when
    final String reason = budgetRepository
            .validateNewBudget(property, new LocalDate(2010, 1, 3), new LocalDate(2010, 1, 1));
    // then
    assertThat(reason).isEqualTo("End date can not be before start date");

}
 
Example 25
Source Project: estatio   Source File: Lease.java    License: Apache License 2.0 5 votes vote down vote up
@Action(semantics = SemanticsOf.IDEMPOTENT)
public Lease verifyUntil(final LocalDate date) {
    for (LeaseItem item : getItems()) {
        LocalDateInterval effectiveInterval = item.getEffectiveInterval();
        item.verifyUntil(ObjectUtils.min(effectiveInterval == null ? null : effectiveInterval.endDateExcluding(), date));
    }
    return this;
}
 
Example 26
Source Project: estatio   Source File: LeaseStatusService_Test.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void suspended() {
    tester(
            LeaseStatus.SUSPENDED,
            new LocalDate(2014, 1, 1), new LocalDate(2015, 3, 31), testItem(null, LeaseItemStatus.SUSPENDED));
    tester(
            LeaseStatus.SUSPENDED,
            new LocalDate(2014, 1, 1), new LocalDate(2015, 3, 31), testItem(null, LeaseItemStatus.SUSPENDED), testItem(null, LeaseItemStatus.SUSPENDED));
}
 
Example 27
Source Project: estatio   Source File: Lease_IntegTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void happyCase() throws Exception {
    // given
    final String newReference = "OXF-MEDIA-001";
    final Lease lease = Lease_enum.OxfTopModel001Gb.findUsing(serviceRegistry);
    final Party newParty = OrganisationAndComms_enum.MediaXGb.findUsing(serviceRegistry);
    final LocalDate newStartDate = VT.ld(2014, 1, 1);

    // when
    Lease newLease = lease.assign(
            newReference,
            newReference,
            newParty,
            newStartDate);

    // then
    assertThat(newLease.getReference()).isEqualTo(newReference);
    assertThat(newLease.getName()).isEqualTo(newReference);
    assertThat(newLease.getStartDate()).isEqualTo(lease.getStartDate());
    assertThat(newLease.getEndDate()).isEqualTo(lease.getEndDate());
    assertThat(newLease.getTenancyStartDate()).isEqualTo(newStartDate);
    assertThat(newLease.getTenancyEndDate()).isNull();
    assertThat(newLease.getPrimaryParty()).isEqualTo(lease.getPrimaryParty());
    assertThat(newLease.getSecondaryParty()).isEqualTo(newParty);
    assertThat(newLease.getItems().size()).isEqualTo(lease.getItems().size());

    assertThat(lease.getTenancyEndDate()).isEqualTo(newStartDate.minusDays(1));
}
 
Example 28
@Override
public void subscribe(YouTubeChannel channel) {
    LocalDate now = LocalDate.now();
    LocalDate expiredAt = channel.getExpiresAt() != null
            ? LocalDate.fromDateFields(channel.getExpiresAt())
            : LocalDate.now();
    if (now.isBefore(expiredAt)) {
        return;
    }

    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
    MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
    map.add("hub.callback", String.format("%s/api/public/youtube/callback/publish?secret=%s&channel=%s",
            commonProperties.getBranding().getWebsiteUrl(),
            apiProperties.getYouTube().getPubSubSecret(),
            CommonUtils.urlEncode(channel.getChannelId())));
    map.add("hub.topic", CHANNEL_RSS_ENDPOINT + channel.getChannelId());
    map.add("hub.mode", "subscribe");
    map.add("hub.verify", "async");
    map.add("hub.verify_token", apiProperties.getYouTube().getPubSubSecret());
    HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(map, headers);

    ResponseEntity<String> response = restTemplate.postForEntity(PUSH_ENDPOINT, request, String.class);
    if (!response.getStatusCode().is2xxSuccessful()) {
        throw new IllegalStateException("Could not subscribe to " + channel.getChannelId());
    }
}
 
Example 29
Source Project: actframework   Source File: FuncTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testToday() {
    Func.Today func = new Func.Today();
    Object obj = func.apply();
    yes(obj instanceof LocalDate);
    LocalDate funcToday = (LocalDate) obj;
    eq(LocalDate.now(), funcToday);
}
 
Example 30
Source Project: estatio   Source File: InvoiceServiceMenu.java    License: Apache License 2.0 5 votes vote down vote up
public String validateCalculate(
        final Lease lease,
        final InvoiceRunType runType,
        final List<LeaseItemType> leaseItemTypes,
        final LocalDate dueDate,
        final LocalDate startDate,
        final LocalDate endDate) {
    return doValidateCalculate(startDate, endDate);
}