Search in sources :

Example 11 with RuleDTO

use of org.commonjava.indy.autoprox.rest.dto.RuleDTO 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()));
}
Also used : CatalogDTO(org.commonjava.indy.autoprox.rest.dto.CatalogDTO) RuleDTO(org.commonjava.indy.autoprox.rest.dto.RuleDTO) File(java.io.File) Test(org.junit.Test)

Example 12 with RuleDTO

use of org.commonjava.indy.autoprox.rest.dto.RuleDTO in project indy by Commonjava.

the class CreateRuleAndVerifyInListingTest method createRuleAndVerifyListingReflectsIt.

@Test
public void createRuleAndVerifyListingReflectsIt() 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());
    final CatalogDTO resultCatalog = module.getCatalog();
    final List<RuleDTO> rules = resultCatalog.getRules();
    assertThat(rules.size(), equalTo(1));
    assertThat(rules.get(0), equalTo(dto));
}
Also used : CatalogDTO(org.commonjava.indy.autoprox.rest.dto.CatalogDTO) RuleDTO(org.commonjava.indy.autoprox.rest.dto.RuleDTO) Test(org.junit.Test)

Aggregations

RuleDTO (org.commonjava.indy.autoprox.rest.dto.RuleDTO)12 Test (org.junit.Test)5 ApiOperation (io.swagger.annotations.ApiOperation)4 ApiResponse (io.swagger.annotations.ApiResponse)4 Response (javax.ws.rs.core.Response)4 CatalogDTO (org.commonjava.indy.autoprox.rest.dto.CatalogDTO)4 ResponseUtils.formatResponse (org.commonjava.indy.bind.jaxrs.util.ResponseUtils.formatResponse)4 ApiResponses (io.swagger.annotations.ApiResponses)3 URL (java.net.URL)3 Path (javax.ws.rs.Path)3 AutoProxRuleException (org.commonjava.indy.autoprox.data.AutoProxRuleException)3 ApiImplicitParams (io.swagger.annotations.ApiImplicitParams)2 IOException (java.io.IOException)2 URI (java.net.URI)2 Consumes (javax.ws.rs.Consumes)2 AutoProxCatalogModule (org.commonjava.indy.autoprox.client.AutoProxCatalogModule)2 File (java.io.File)1 DELETE (javax.ws.rs.DELETE)1 GET (javax.ws.rs.GET)1 POST (javax.ws.rs.POST)1