Search in sources :

Example 1 with ProxyConnectorRuleService

use of org.apache.archiva.rest.api.services.ProxyConnectorRuleService in project archiva by apache.

the class ProxyConnectorRuleServiceTest method addProxyConnectorRule.

@Test
public void addProxyConnectorRule() throws Exception {
    ProxyConnector proxyConnector = new ProxyConnector();
    proxyConnector.setSourceRepoId("snapshots");
    proxyConnector.setTargetRepoId("central");
    ProxyConnectorRuleService service = getProxyConnectorRuleService(authorizationHeader);
    ProxyConnectorRule rule = null;
    try {
        int size = service.getProxyConnectorRules().size();
        assertEquals(0, size);
        getProxyConnectorService().addProxyConnector(proxyConnector);
        rule = new ProxyConnectorRule("org/apache/maven", ProxyConnectorRuleType.BLACK_LIST, Arrays.asList(proxyConnector));
        service.addProxyConnectorRule(rule);
        assertEquals(size + 1, service.getProxyConnectorRules().size());
        rule = service.getProxyConnectorRules().get(0);
        assertEquals("org/apache/maven", rule.getPattern());
        assertEquals(1, rule.getProxyConnectors().size());
        assertEquals("snapshots", rule.getProxyConnectors().get(0).getSourceRepoId());
        assertEquals("central", rule.getProxyConnectors().get(0).getTargetRepoId());
        assertEquals(ProxyConnectorRuleType.BLACK_LIST, rule.getProxyConnectorRuleType());
    } finally {
        service.deleteProxyConnectorRule(rule);
        getProxyConnectorService().deleteProxyConnector(proxyConnector);
    }
}
Also used : ProxyConnectorRule(org.apache.archiva.admin.model.beans.ProxyConnectorRule) ProxyConnector(org.apache.archiva.admin.model.beans.ProxyConnector) ProxyConnectorRuleService(org.apache.archiva.rest.api.services.ProxyConnectorRuleService) Test(org.junit.Test)

Aggregations

ProxyConnector (org.apache.archiva.admin.model.beans.ProxyConnector)1 ProxyConnectorRule (org.apache.archiva.admin.model.beans.ProxyConnectorRule)1 ProxyConnectorRuleService (org.apache.archiva.rest.api.services.ProxyConnectorRuleService)1 Test (org.junit.Test)1