use of org.commonjava.indy.autoprox.rest.dto.RuleDTO in project indy by Commonjava.
the class AutoProxCatalogResource method getRule.
@ApiOperation(value = "Retrieve a single AutoProx rule", response = RuleDTO.class)
@ApiResponses({ @ApiResponse(code = 404, message = "No rule by the specified name"), @ApiResponse(code = 200, message = "Rule spec sent") })
@GET
@Path("{name}")
public Response getRule(@PathParam("name") final String name) {
Response response = checkEnabled();
if (response != null) {
return response;
}
final RuleDTO dto = controller.getRule(name);
if (dto == null) {
return Response.status(Status.NOT_FOUND).build();
} else {
return formatOkResponseWithJsonEntity(dto, serializer);
}
}
use of org.commonjava.indy.autoprox.rest.dto.RuleDTO in project indy by Commonjava.
the class AbstractAutoproxCalculatorTest method installRule.
protected RuleDTO installRule(final String named, final String ruleScriptResource) throws IOException, IndyClientException {
final URL resource = Thread.currentThread().getContextClassLoader().getResource(ruleScriptResource);
if (resource == null) {
Assert.fail("Cannot find classpath resource: " + ruleScriptResource);
}
final String spec = IOUtils.toString(resource);
return client.module(AutoProxCatalogModule.class).storeRule(new RuleDTO(named, spec));
}
use of org.commonjava.indy.autoprox.rest.dto.RuleDTO in project indy by Commonjava.
the class AbstractAutoproxDeletionTest method installRule.
protected RuleDTO installRule(final String named, final String ruleScriptResource) throws IOException, IndyClientException {
final URL resource = Thread.currentThread().getContextClassLoader().getResource(ruleScriptResource);
if (resource == null) {
Assert.fail("Cannot find classpath resource: " + ruleScriptResource);
}
String spec = IOUtils.toString(resource);
spec = spec.replace("@baseUri@", http.getBaseUri());
return client.module(AutoProxCatalogModule.class).storeRule(new RuleDTO(named, spec));
}
use of org.commonjava.indy.autoprox.rest.dto.RuleDTO in project indy by Commonjava.
the class CreateRuleFailsWhenAutoProxDisabledTest method createRuleAndVerifyListingReflectsIt.
@Test(expected = IndyClientException.class)
public void createRuleAndVerifyListingReflectsIt() throws Exception {
final RuleDTO rule = getRule("0001-simple-rule", "rules/simple-rule.groovy");
final RuleDTO dto = module.storeRule(rule);
}
use of org.commonjava.indy.autoprox.rest.dto.RuleDTO 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));
}
Aggregations