Package com.airhacks.workshops.business.registrations.entity

Examples of com.airhacks.workshops.business.registrations.entity.Registration


    public static final String CONFIRMATION_ID = "confirmation-id";

    public JsonObject register(Registration request) {
        tracer.info("registration arrived: " + request);
        Registration registration = em.merge(request);
        tracer.info("registration stored: " + request);
        registration.setCalculator(priceCalculator::calculateTotal);
        tracer.info("price computed: " + registration.getTotalPrice());
        return convert(registration);
    }
View Full Code Here


    }

    @GET
    @Path("{id}/dummy")
    public Registration dummy(@PathParam("id") int registrationId) {
        return new Registration(true, 1, 1);
    }
View Full Code Here

    }

    @Test
    public void successfulRegistration() {
        when(this.cut.priceCalculator.calculateTotal(Matchers.anyBoolean(), Matchers.anyInt())).thenReturn(1);
        Registration registration = new Registration(true, 1, 1);
        merge(registration);
        this.cut.register(registration);
    }
View Full Code Here

        assertTrue(result.isEmpty());
    }

    public void convertFilledListToJson() {
        List<Registration> registrations = new ArrayList<>();
        Registration expected = mock(Registration.class);
        when(expected.getId()).thenReturn(42l);
        registrations.add(expected);
        mockQuery(Registration.findAll, registrations);
        final JsonArray result = this.cut.allAsJson();
        assertNotNull(result);
        assertThat(result.size(), is(1));
        JsonObject actual = result.getJsonObject(0);
        JsonNumber actualId = actual.getJsonNumber(Registrations.CONFIRMATION_ID);
        assertThat(expected.getId(), is(actualId.longValue()));

    }
View Full Code Here

    }

    @Test
    public void successfulRegistration() {
        when(this.cut.priceCalculator.calculateTotal(Matchers.anyBoolean(), Matchers.anyInt())).thenReturn(1);
        Registration registration = new Registration(true, 1, 1);
        merge(registration);
        this.cut.register(registration);
    }
View Full Code Here

    }

    @Test
    public void convertFilledListToJson() {
        List<Registration> registrations = new ArrayList<>();
        Registration expected = mock(Registration.class);
        when(expected.getId()).thenReturn(42l);
        registrations.add(expected);
        mockQuery(Registration.findAll, registrations);
        final JsonArray result = this.cut.allAsJson();
        assertNotNull(result);
        assertThat(result.size(), is(1));
        JsonObject actual = result.getJsonObject(0);
        JsonNumber actualId = actual.getJsonNumber(Registrations.CONFIRMATION_ID);
        assertThat(expected.getId(), is(actualId.longValue()));

    }
View Full Code Here

    public static final String CONFIRMATION_ID = "confirmation-id";

    public JsonObject register(Registration request) {
        tracer.info("registration arrived: " + request);
        Registration registration = em.merge(request);
        tracer.info("registration stored: " + request);
        registration.setCalculator(priceCalculator::calculateTotal);
        tracer.info("price computed: " + registration.getTotalPrice());
        return convert(registration);
    }
View Full Code Here

    }

    @GET
    @Path("{id}/dummy")
    public Registration dummy(@PathParam("id") int registrationId) {
        return new Registration(registrationId);
    }
View Full Code Here

    @Inject
    VatCalculator priceCalculator;

    public Registration register(Registration request) {
        Registration registration = em.merge(request);
        registration.setCalculator(priceCalculator::calculateTotal);
        return registration;
    }
View Full Code Here

    @Inject
    VatCalculator calculator;

    @POST
    public Response register(Registration request, @Context UriInfo info) {
        Registration registration = registrations.register(request);
        long id = registration.getId();
        URI uri = info.getAbsolutePathBuilder().path("/" + id).build();
        JsonObject confirmation = Json.createObjectBuilder().
                add("price", registration.getTotalPrice()).
                add("confirmation-id", registration.getId()).build();
        return Response.created(uri).entity(confirmation).build();
    }
View Full Code Here

TOP

Related Classes of com.airhacks.workshops.business.registrations.entity.Registration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.