Search in sources :

Example 1 with PersistableOptin

use of com.salesmanager.shop.model.system.PersistableOptin in project shopizer by shopizer-ecommerce.

the class OptinFacadeImpl method create.

@Override
public ReadableOptin create(PersistableOptin persistableOptin, MerchantStore merchantStore, Language language) {
    Optin optinEntity = persistableOptinConverter.convert(persistableOptin, merchantStore, language);
    Optin savedOptinEntity = createOptin(optinEntity);
    return readableOptinConverter.convert(savedOptinEntity, merchantStore, language);
}
Also used : ReadableOptin(com.salesmanager.shop.model.system.ReadableOptin) Optin(com.salesmanager.core.model.system.optin.Optin) PersistableOptin(com.salesmanager.shop.model.system.PersistableOptin)

Example 2 with PersistableOptin

use of com.salesmanager.shop.model.system.PersistableOptin in project shopizer by shopizer-ecommerce.

the class PersistableOptinMapper method convert.

@Override
public Optin convert(PersistableOptin source, MerchantStore store, Language language) {
    Optin optinEntity = new Optin();
    optinEntity.setCode(source.getCode());
    optinEntity.setDescription(source.getDescription());
    optinEntity.setOptinType(OptinType.valueOf(source.getOptinType()));
    optinEntity.setMerchant(store);
    return optinEntity;
}
Also used : Optin(com.salesmanager.core.model.system.optin.Optin) PersistableOptin(com.salesmanager.shop.model.system.PersistableOptin)

Example 3 with PersistableOptin

use of com.salesmanager.shop.model.system.PersistableOptin in project shopizer by shopizer-ecommerce.

the class OptinApiIntegrationTest method createOptin.

@Test
public void createOptin() throws Exception {
    PersistableOptin optin = new PersistableOptin();
    optin.setCode(OptinType.PROMOTIONS.name());
    optin.setOptinType(OptinType.PROMOTIONS.name());
    final ObjectWriter writer = new ObjectMapper().writer().withDefaultPrettyPrinter();
    final String json = writer.writeValueAsString(optin);
    final HttpEntity<String> entity = new HttpEntity<>(json, getHeader());
    final ResponseEntity<PersistableOptin> response = testRestTemplate.postForEntity("/api/v1/private/optin", entity, PersistableOptin.class);
    if (response.getStatusCode() != HttpStatus.OK) {
        throw new Exception(response.toString());
    } else {
        assertTrue(true);
    }
}
Also used : HttpEntity(org.springframework.http.HttpEntity) PersistableOptin(com.salesmanager.shop.model.system.PersistableOptin) ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

PersistableOptin (com.salesmanager.shop.model.system.PersistableOptin)3 Optin (com.salesmanager.core.model.system.optin.Optin)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)1 ReadableOptin (com.salesmanager.shop.model.system.ReadableOptin)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 HttpEntity (org.springframework.http.HttpEntity)1