use of org.commonjava.indy.autoprox.rest.dto.CatalogDTO in project indy by Commonjava.
the class AutoProxCatalogResource method getCatalog.
@ApiOperation(value = "Retrieve the AutoProx rule catalog", response = CatalogDTO.class)
@ApiResponses({ @ApiResponse(code = 404, message = "AutoProx is disabled or no rules are defined."), @ApiResponse(code = 200, message = "Catalog sent") })
@GET
@Produces(ApplicationContent.application_json)
public Response getCatalog() {
Response response = checkEnabled();
if (response != null) {
return response;
}
final CatalogDTO dto = controller.getCatalog();
if (dto == null) {
return Response.status(Status.NOT_FOUND).build();
}
return formatOkResponseWithJsonEntity(dto, serializer);
}
use of org.commonjava.indy.autoprox.rest.dto.CatalogDTO in project indy by Commonjava.
the class ListExistingCatalogTest method listDefaultCatalog.
@Test
public void listDefaultCatalog() throws Exception {
try {
final CatalogDTO catalog = module.getCatalog();
assertThat(catalog.isEnabled(), equalTo(true));
} catch (Exception e) {
logger.error("Test error", e);
throw e;
}
}
use of org.commonjava.indy.autoprox.rest.dto.CatalogDTO in project indy by Commonjava.
the class CreateAndVerifyRuleTest method createRuleAndVerifyRetrieval.
@Test
public void createRuleAndVerifyRetrieval() throws Exception {
final CatalogDTO catalog = module.getCatalog();
assertThat(catalog.isEnabled(), equalTo(true));
assertThat(catalog.getRules().isEmpty(), equalTo(true));
final RuleDTO rule = getRule("0001-simple-rule", "rules/simple-rule.groovy");
final RuleDTO dto = module.storeRule(rule);
assertThat(dto, notNullValue());
assertThat(dto, equalTo(rule));
}
use of org.commonjava.indy.autoprox.rest.dto.CatalogDTO in project indy by Commonjava.
the class CreateAndDeleteRuleTest method createRuleDeleteAndVerifyMissing.
@Test
public void createRuleDeleteAndVerifyMissing() throws Exception {
final CatalogDTO catalog = module.getCatalog();
assertThat(catalog.isEnabled(), equalTo(true));
assertThat(catalog.getRules().isEmpty(), equalTo(true));
final RuleDTO rule = getRule("0001-simple-rule", "rules/simple-rule.groovy");
RuleDTO dto = module.storeRule(rule);
assertThat(dto, notNullValue());
assertThat(dto, equalTo(rule));
module.deleteRuleNamed(dto.getName());
dto = module.getRuleNamed(dto.getName());
assertThat(dto, nullValue());
}
use of org.commonjava.indy.autoprox.rest.dto.CatalogDTO in project indy by Commonjava.
the class ReparsePicksUpNewRuleFileTest method writeRuleFileThenReparseCatalogAndVerifyRulePresence.
@Test
public void writeRuleFileThenReparseCatalogAndVerifyRulePresence() throws Exception {
final CatalogDTO catalog = module.getCatalog();
assertThat(catalog.isEnabled(), equalTo(true));
assertThat(catalog.getRules().isEmpty(), equalTo(true));
final RuleDTO rule = getRule("0001-simple-rule.groovy", "rules/simple-rule.groovy");
final File script = new File(fixture.getBootOptions().getIndyHome(), "var/lib/indy/data/autoprox/0001-simple-rule.groovy");
FileUtils.write(script, rule.getSpec());
module.reparseCatalog();
final CatalogDTO resultCatalog = module.getCatalog();
final List<RuleDTO> rules = resultCatalog.getRules();
assertThat(rules.size(), equalTo(1));
final RuleDTO dto = rules.get(0);
assertThat(dto.getName(), equalTo(FilenameUtils.removeExtension(rule.getName())));
assertThat(dto.getSpec(), equalTo(rule.getSpec()));
}
Aggregations