use of com.salesmanager.shop.model.entity.EntityExists in project shopizer by shopizer-ecommerce.
the class TaxRateIntegrationTest method manageTaxRates.
@Test
public void manageTaxRates() throws Exception {
// create tax class
PersistableTaxRate taxRate = new PersistableTaxRate();
taxRate.setCode("taxcode1");
taxRate.setCountry("US");
taxRate.setPriority(0);
taxRate.setRate(new BigDecimal(5));
taxRate.setStore("DEFAULT");
taxRate.setTaxClass("DEFAULT");
taxRate.setZone("NY");
// descriptions
TaxRateDescription en = new TaxRateDescription();
en.setLanguage("en");
en.setName("TaxCode1EN");
en.setDescription("TaxCode1EN description");
TaxRateDescription fr = new TaxRateDescription();
fr.setLanguage("fr");
fr.setName("TaxCode1FR");
fr.setDescription("TaxCode1fr description");
taxRate.getDescriptions().add(en);
taxRate.getDescriptions().add(fr);
final HttpEntity<PersistableTaxRate> taxClassEntity = new HttpEntity<>(taxRate, getHeader());
final ResponseEntity<Entity> response = testRestTemplate.postForEntity(String.format("/api/v1/private/tax/rate/"), taxClassEntity, Entity.class);
Entity e = response.getBody();
assertNotNull(e.getId());
assertTrue(e.getId() > 0);
final HttpEntity<String> httpEntity = new HttpEntity<>(getHeader());
// tax class exists
final ResponseEntity<EntityExists> exists = testRestTemplate.exchange(String.format("/api/v1/private/tax/rate/unique?code=" + taxRate.getCode()), HttpMethod.GET, httpEntity, EntityExists.class);
assertTrue(exists.getBody().isExists());
}
use of com.salesmanager.shop.model.entity.EntityExists in project shopizer by shopizer-ecommerce.
the class ContentApi method boxExists.
@GetMapping(value = "/private/content/box/{code}/exists")
@ResponseStatus(HttpStatus.OK)
@ApiOperation(httpMethod = "GET", value = "Check unique content box", notes = "", response = EntityExists.class)
@ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "String", defaultValue = "DEFAULT"), @ApiImplicitParam(name = "lang", dataType = "String", defaultValue = "en") })
public EntityExists boxExists(@PathVariable String code, @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) {
boolean exists = contentFacade.codeExist(code, BOX, merchantStore);
EntityExists entity = new EntityExists(exists);
return entity;
}
use of com.salesmanager.shop.model.entity.EntityExists in project shopizer by shopizer-ecommerce.
the class ContentApi method pageExists.
@GetMapping(value = "/private/content/page/{code}/exists")
@ResponseStatus(HttpStatus.OK)
@ApiOperation(httpMethod = "GET", value = "Check unique content page", notes = "", response = EntityExists.class)
@ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "String", defaultValue = "DEFAULT"), @ApiImplicitParam(name = "lang", dataType = "String", defaultValue = "en") })
public EntityExists pageExists(@PathVariable String code, @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) {
boolean exists = contentFacade.codeExist(code, PAGE, merchantStore);
EntityExists entity = new EntityExists(exists);
return entity;
}
use of com.salesmanager.shop.model.entity.EntityExists in project shopizer by shopizer-ecommerce.
the class ProductInstanceApi method exists.
@ResponseStatus(HttpStatus.OK)
@GetMapping(value = { "/private/product/{id}/instance/{sku}/unique" }, produces = MediaType.APPLICATION_JSON_VALUE)
@ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "string", defaultValue = "DEFAULT"), @ApiImplicitParam(name = "lang", dataType = "string", defaultValue = "en") })
@ApiOperation(httpMethod = "GET", value = "Check if option set code already exists", notes = "", response = EntityExists.class)
@ResponseBody
public ResponseEntity<EntityExists> exists(@PathVariable Long id, @RequestParam(value = "code") String sku, @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) {
String authenticatedUser = userFacade.authenticatedUser();
if (authenticatedUser == null) {
throw new UnauthorizedException();
}
userFacade.authorizedGroup(authenticatedUser, Stream.of(Constants.GROUP_SUPERADMIN, Constants.GROUP_ADMIN, Constants.GROUP_ADMIN_CATALOGUE, Constants.GROUP_ADMIN_RETAIL).collect(Collectors.toList()));
boolean exist = productInstanceFacade.exists(sku, merchantStore, id, language);
return new ResponseEntity<EntityExists>(new EntityExists(exist), HttpStatus.OK);
}
use of com.salesmanager.shop.model.entity.EntityExists in project shopizer by shopizer-ecommerce.
the class TaxRateIntegrationTest method manageTaxClass.
@Test
public void manageTaxClass() throws Exception {
// create tax class
PersistableTaxClass taxClass = new PersistableTaxClass();
taxClass.setCode("TESTTX");
taxClass.setName("Test tax class");
final HttpEntity<PersistableTaxClass> taxClassEntity = new HttpEntity<>(taxClass, getHeader());
final ResponseEntity<Entity> response = testRestTemplate.postForEntity(String.format("/api/v1/private/tax/class/"), taxClassEntity, Entity.class);
Entity e = response.getBody();
assertNotNull(e.getId());
assertTrue(e.getId() > 0);
final HttpEntity<String> httpEntity = new HttpEntity<>(getHeader());
// tax class exists
final ResponseEntity<EntityExists> exists = testRestTemplate.exchange(String.format("/api/v1/private/tax/class/unique?code=" + taxClass.getCode()), HttpMethod.GET, httpEntity, EntityExists.class);
assertTrue(exists.getBody().isExists());
/**
* //list 1 taxClass
* @SuppressWarnings("rawtypes")
* final ResponseEntity<ReadableEntityList> listOfTaxClasses = testRestTemplate.exchange(String.format("/private/tax/class"), HttpMethod.GET,
* httpEntity, ReadableEntityList.class);
*
* assertTrue(listOfTaxClasses.getBody().getRecordsTotal() == 1);
*/
}
Aggregations