当前位置: 首页>>代码示例>>Java>>正文


Java F类代码示例

本文整理汇总了Java中play.libs.F的典型用法代码示例。如果您正苦于以下问题:Java F类的具体用法?Java F怎么用?Java F使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


F类属于play.libs包,在下文中一共展示了F类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: call

import play.libs.F; //导入依赖的package包/类
public F.Promise<SimpleResult> call(Context ctx) {
    try {
        final String key = configuration.key();
        final Integer duration = configuration.duration();
        SimpleResult result = (SimpleResult) Cache.get(key);
        F.Promise<SimpleResult> promise;
        if(result == null) {
            promise = delegate.call(ctx);
            promise.onRedeem(new F.Callback<SimpleResult>() {
                @Override
                public void invoke(SimpleResult simpleResult) throws Throwable {
                    Cache.set(key, simpleResult, duration);
                }
            });
        } else {
            promise = F.Promise.pure(result);
        }
        return promise;
    } catch(RuntimeException e) {
        throw e;
    } catch(Throwable t) {
        throw new RuntimeException(t);
    }
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:25,代码来源:CachedAction.java

示例2: call

import play.libs.F; //导入依赖的package包/类
public F.Promise<SimpleResult> call(Context ctx) {
    try {
        Authenticator authenticator = configuration.value().newInstance();
        String username = authenticator.getUsername(ctx);
        if(username == null) {
            Result unauthorized = authenticator.onUnauthorized(ctx);
            if (unauthorized instanceof AsyncResult) {
                return ((AsyncResult) unauthorized).getPromise();
            } else {
                return F.Promise.pure((SimpleResult) unauthorized);
            }
        } else {
            try {
                ctx.request().setUsername(username);
                return delegate.call(ctx);
            } finally {
                ctx.request().setUsername(null);
            }
        }
    } catch(RuntimeException e) {
        throw e;
    } catch(Throwable t) {
        throw new RuntimeException(t);
    }
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:26,代码来源:Security.java

示例3: errorsAsJson

import play.libs.F; //导入依赖的package包/类
@Test
public void errorsAsJson() {
    running(fakeApplication(), new Runnable() {
        @Override
        public void run() {
            Lang lang = new Lang(new play.api.i18n.Lang("en", ""));
            
            Map<String, List<ValidationError>> errors = new HashMap<String, List<ValidationError>>();
            List<ValidationError> error = new ArrayList<ValidationError>();
            error.add(new ValidationError("foo", RequiredValidator.message, new ArrayList<Object>()));
            errors.put("foo", error);
            
            DynamicForm form = new DynamicForm(new HashMap<String, String>(), errors, F.None());
            
            JsonNode jsonErrors = form.errorsAsJson(lang);
            assertThat(jsonErrors.findPath("foo").iterator().next().asText()).isEqualTo(play.i18n.Messages.get(lang, RequiredValidator.message));
        }
    });
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:20,代码来源:SimpleTest.java

示例4: paymentTodayPresent

import play.libs.F; //导入依赖的package包/类
public static F.Promise<Result> paymentTodayPresent() {
    JsonNode key = keystoreConnector.getKey(session("uuid")).get(timeout);
    Form<CalculatorPaymentToday> form = form(CalculatorPaymentToday.class);

    if(Optional.ofNullable(key).isPresent()) {
        JsonNode amountsDue = key.get("data").get("calculator-amounts-due-form");
        JsonNode paymentToday = key.get("data").get("calculator-payment-today-form");

        if (Optional.ofNullable(amountsDue).isPresent()) {

            if (Optional.ofNullable(paymentToday).isPresent())
                return F.Promise.promise(() -> ok(payment_today_form.render(Form.form(CalculatorPaymentToday.class)
                            .fill(fromJson(paymentToday, CalculatorPaymentToday.class)))));
            else
                return F.Promise.promise(() -> ok(payment_today_form.render(form)));
        } else return F.Promise.promise(() -> redirect(routes.CalculatorController.amountsDuePresent()));
    } else return F.Promise.promise(() -> redirect(routes.CalculatorController.amountsDuePresent()));
}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:19,代码来源:CalculatorController.java

示例5: resultsSubmit

import play.libs.F; //导入依赖的package包/类
public static F.Promise<Result> resultsSubmit() {
    final Integer monthsToShow;
    String formMonths = form().bindFromRequest().get("months_to_show");
    if (formMonths != null) {
        monthsToShow = Ints.tryParse(formMonths);
    } else {
        monthsToShow = 3;
    }

    List<PaymentSchedule> schedules = getPaymentSchedules(monthsToShow);

    final PaymentSchedule scheduleToShow;

    if (Optional.ofNullable(monthsToShow).isPresent()) {
        scheduleToShow = schedules.stream().filter(s -> s.getInstalments().size() == monthsToShow).findFirst().orElse(schedules.stream().findFirst().get());
    } else {
        scheduleToShow = schedules.stream().findFirst().get();
    }
    List<Integer> availableOptions = schedules.stream().map(s -> s.getInstalments().size()).collect(Collectors.toList());
    return F.Promise.promise(() -> ok(results.render(scheduleToShow, availableOptions)));
}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:22,代码来源:CalculatorController.java

示例6: debtTypePresent

import play.libs.F; //导入依赖的package包/类
public static F.Promise<Result> debtTypePresent() {
    JsonNode key = keystoreConnector.getKey(session("uuid")).get(SsttpFrontendConfig.timeout);
    Form<EligibilityDebtType> form = Form.form(EligibilityDebtType.class);

    if(Optional.ofNullable(key).isPresent()) {
        if(Optional.ofNullable(key.get("data").get("service-start")).isPresent()) {

            JsonNode debtType = key.get("data").get("eligibility-debt-type-form");

            if(Optional.ofNullable(debtType).isPresent()) {
                return F.Promise.promise(() -> ok(debt_type.render(Form.form(EligibilityDebtType.class)
                            .fill(fromJson(debtType, EligibilityDebtType.class)))));
            } else return F.Promise.promise(() -> ok(debt_type.render(form)));
        } else
            return F.Promise.promise(() -> redirect(routes.SelfServiceTimeToPayController.serviceStart()));
    } else return F.Promise.promise(() -> ok(debt_type.render(form)));
}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:18,代码来源:EligibilityController.java

示例7: debtTypeSubmit

import play.libs.F; //导入依赖的package包/类
public static F.Promise<Result> debtTypeSubmit() {
    Form<EligibilityDebtType> form = Form.form(EligibilityDebtType.class).bindFromRequest();

    if(form.hasErrors()) {
        return F.Promise.promise(() -> ok(debt_type.render(form)));
    } else {
        EligibilityDebtType debtTypeAnswer = form.get();
        Logger.debug(toJson(debtTypeAnswer).toString());
        String uuid = session("uuid");

        if(Optional.ofNullable(uuid).isPresent())
            keystoreConnector.putKey(toJson(debtTypeAnswer), uuid, "eligibility-debt-type-form");

        if(debtTypeAnswer.isOtherTaxDebt()) {
            return F.Promise.promise(() -> redirect(routes.SelfServiceTimeToPayController.ttpCallUs()));
        } else {
            return F.Promise.promise(() -> redirect(routes.EligibilityController.existingTtpPresent()));
        }
    }
}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:21,代码来源:EligibilityController.java

示例8: existingTtpPresent

import play.libs.F; //导入依赖的package包/类
public static F.Promise<Result> existingTtpPresent() {
    JsonNode key = keystoreConnector.getKey(session("uuid")).get(SsttpFrontendConfig.timeout);
    Form<EligibilityExistingTTP> form = Form.form(EligibilityExistingTTP.class);

    if(Optional.ofNullable(key).isPresent()) {
        JsonNode debtType = key.get("data").get("eligibility-debt-type-form");
        JsonNode existingTtp = key.get("data").get("eligibility-existing-ttp-form");
        if(Optional.ofNullable(debtType).isPresent()) {
            if(Optional.ofNullable(existingTtp).isPresent())
                return F.Promise.promise(() ->
                        ok(existing_ttp.render(Form.form(EligibilityExistingTTP.class).fill(fromJson(existingTtp, EligibilityExistingTTP.class)))));
            else return F.Promise.promise(() -> ok(existing_ttp.render(form)));
        } else
            return F.Promise.promise(() -> redirect(routes.EligibilityController.present()));
    } else return F.Promise.promise(() -> ok(existing_ttp.render(form)));

}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:18,代码来源:EligibilityController.java

示例9: existingTtpSubmit

import play.libs.F; //导入依赖的package包/类
public static F.Promise<Result> existingTtpSubmit() {
    Form<EligibilityExistingTTP> form = Form.form(EligibilityExistingTTP.class).bindFromRequest();

    if (form.hasErrors()) {
        return F.Promise.promise(() -> ok(existing_ttp.render(form)));
    } else {
        EligibilityExistingTTP existingTtpAnswer = form.get();
        String uuid = session("uuid");
        if(Optional.ofNullable(uuid).isPresent())
            keystoreConnector.putKey(toJson(existingTtpAnswer), uuid, "eligibility-existing-ttp-form");
        if(existingTtpAnswer.getExistingTTP()) {
            return F.Promise.promise(() -> redirect(routes.SelfServiceTimeToPayController.ttpCallUs()));
        } else {
            return F.Promise.promise(() -> redirect(routes.CalculatorController.present()));
        }
    }
}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:18,代码来源:EligibilityController.java

示例10: sendUserInput

import play.libs.F; //导入依赖的package包/类
public F.Promise<List<PaymentSchedule>> sendUserInput(CalculatorInput calcInput) {

        String calculatorUrl = String.format("%s/%s", baseUrl, "paymentschedule");

        Logger.debug(toJson(calcInput).toString());

        F.Promise<WSResponse> result = WS.url(calculatorUrl).post(toJson(calcInput));

        return result.map(r -> {
            if (r.getStatus() != 200) {
                return new ArrayList<PaymentSchedule>();
            } else {
                return Arrays.asList(fromJson(r.asJson(), PaymentSchedule[].class));
            }
        });
    }
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:17,代码来源:SelfAssessmentConnector.java

示例11: displayAmountsDue

import play.libs.F; //导入依赖的package包/类
@Test
public void displayAmountsDue() {
    running(fakeApplication(new SsttpFrontendGlobal()), () -> {
        CalculatorController calculatorController = new CalculatorController();
        calculatorController.keystoreConnector = mock(KeystoreConnector.class);

        when(calculatorController.keystoreConnector.getKey("1")).thenReturn(F.Promise.promise(() -> (tree)));

        Result result = callAction(routes.ref.CalculatorController.amountsDuePresent(),
                fakeRequest()
                        .withHeader("referer", "/self-service-time-to-pay")
                        .withSession("uuid", uuid).withSession("timestamp", timestamp));

        String body = Helpers.contentAsString(result);

        assertThat(status(result), is(Http.Status.OK));
        assertThat(body, containsString(Messages.get("ssttp.calculator.form.amounts_due.title")));
    });
}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:20,代码来源:CalculatorControllerTest.java

示例12: displayPaymentTodayPresent

import play.libs.F; //导入依赖的package包/类
@Test
public void displayPaymentTodayPresent() {
    running(fakeApplication(new SsttpFrontendGlobal()), () -> {
        CalculatorController calculatorController = new CalculatorController();
        calculatorController.keystoreConnector = mock(KeystoreConnector.class);

        when(calculatorController.keystoreConnector.getKey("1")).thenReturn(F.Promise.promise(() -> (tree)));

        Result result = callAction(routes.ref.CalculatorController.paymentTodayPresent(),
                fakeRequest()
                        .withHeader("referer", "/self-service-time-to-pay")
                        .withSession("uuid", uuid).withSession("timestamp", timestamp));

        String body = Helpers.contentAsString(result);

        assertThat(status(result), is(Http.Status.OK));
        assertThat(body, containsString(Messages.get("ssttp.calculator.form.payment_today.title")));
    });
}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:20,代码来源:CalculatorControllerTest.java

示例13: submitPaymentTodayNoErrors

import play.libs.F; //导入依赖的package包/类
@Test
public void submitPaymentTodayNoErrors() {
    running(fakeApplication(new SsttpFrontendGlobal()), () -> {
        Map<String, String> formData = Maps.newHashMap();
        formData.put("amount", "345");
        CalculatorController calculatorController = new CalculatorController();
        calculatorController.keystoreConnector = mock(KeystoreConnector.class);
        calculatorController.connector = mock(SelfAssessmentConnector.class);

        when(calculatorController.keystoreConnector.getKey("1")).thenReturn(F.Promise.promise(() -> (tree)));
        when(calculatorController.connector.sendUserInput(any(CalculatorInput.class)))
                .thenReturn(F.Promise.promise(() -> (
                        Arrays.asList(fromJson(calculatorResponseTree, PaymentSchedule[].class)))));

        Result result = callAction(routes.ref.CalculatorController.paymentTodaySubmit(),
                fakeRequest()
                        .withSession("uuid", uuid).withSession("timestamp", timestamp)
                        .withFormUrlEncodedBody(formData));

        String body = Helpers.contentAsString(result);

        // should display payment summary page
        assertThat(status(result), is(Http.Status.OK));
        assertThat(body, containsString(Messages.get("ssttp.calculator.results.title")));
    });
}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:27,代码来源:CalculatorControllerTest.java

示例14: presentDebtTypePage

import play.libs.F; //导入依赖的package包/类
@Test
public void presentDebtTypePage() {
    running(fakeApplication(new SsttpFrontendGlobal()), () -> {
        Map<String, String> formData = Maps.newHashMap();
        EligibilityController eligibility = new EligibilityController();
        eligibility.keystoreConnector = mock(KeystoreConnector.class);

        when(eligibility.keystoreConnector.getKey("1")).thenReturn(F.Promise.promise(() -> (tree)));

        Result result = callAction(routes.ref.EligibilityController.debtTypePresent(),
                fakeRequest()
                        .withSession("uuid", uuid).withSession("timestamp", timestamp)
                        .withFormUrlEncodedBody(formData));
        String body = Helpers.contentAsString(result);

        assertThat(status(result), is(Http.Status.OK));
        assertThat(body, containsString(Messages.get("ssttp.eligibility.form.debt_type.title")));

    });
}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:21,代码来源:EligibilityControllerTest.java

示例15: presentExistingTtpPage

import play.libs.F; //导入依赖的package包/类
@Test
public void presentExistingTtpPage() {
    running(fakeApplication(new SsttpFrontendGlobal()), () -> {
        Map<String, String> formData = Maps.newHashMap();

        EligibilityDebtType form = new EligibilityDebtType(true, false);
        EligibilityController eligibilityController = new EligibilityController();
        eligibilityController.keystoreConnector = mock(KeystoreConnector.class);

        when(eligibilityController.keystoreConnector.getKey("1")).thenReturn(F.Promise.promise(() -> (tree)));

        Result result = callAction(routes.ref.EligibilityController.existingTtpPresent(),
                    fakeRequest()
                            .withSession("uuid", uuid).withSession("timestamp", timestamp)
                            .withFormUrlEncodedBody(formData).withSession("uuid", uuid));
        String body = Helpers.contentAsString(result);

        assertThat(status(result), is(Http.Status.OK));
        assertThat(body, containsString(Messages.get("ssttp.eligibility.form.existing_ttp.title")));
    });
}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:22,代码来源:EligibilityControllerTest.java


注:本文中的play.libs.F类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。