use of org.commonjava.indy.autoprox.rest.dto.AutoProxCalculation in project indy by Commonjava.
the class AutoProxCalculatorResource method eval.
@ApiOperation(value = "Calculate the effects of referencing a store with the given type and name to determine what AutoProx will auto-create", response = AutoProxCalculation.class)
@ApiResponse(code = 200, message = "Result of calculation")
@Path("/{packageType}/{type: (hosted|group|remote)}/{name}")
@GET
@Produces(ApplicationContent.application_json)
public Response eval(@PathParam("packageType") final String packageType, @PathParam("type") final String type, @PathParam("name") final String remoteName) {
Response response = checkEnabled();
if (response != null) {
return response;
}
try {
StoreKey key = new StoreKey(packageType, StoreType.get(type), remoteName);
final AutoProxCalculation calc = controller.eval(key);
response = formatOkResponseWithJsonEntity(serializer.writeValueAsString(calc == null ? Collections.singletonMap("error", "Nothing was created") : calc));
} catch (final IndyWorkflowException e) {
logger.error(String.format("Failed to create demo RemoteRepository for: '%s'. Reason: %s", remoteName, e.getMessage()), e);
response = formatResponse(e);
} catch (final JsonProcessingException e) {
logger.error(String.format("Failed to create demo RemoteRepository for: '%s'. Reason: %s", remoteName, e.getMessage()), e);
response = formatResponse(e);
}
return response;
}
use of org.commonjava.indy.autoprox.rest.dto.AutoProxCalculation in project indy by Commonjava.
the class CalculateGroupReturn400WhenDisabledTest method calculate.
@Test(expected = IndyClientException.class)
public void calculate() throws Exception {
final String name = "test";
final AutoProxCalculation calculation = module.calculateRuleOutput(StoreType.group, name);
}
use of org.commonjava.indy.autoprox.rest.dto.AutoProxCalculation in project indy by Commonjava.
the class CalculateHostedRepoTest method calculate.
@Test
public void calculate() throws Exception {
final String name = "test";
final AutoProxCalculation calculation = module.calculateRuleOutput(StoreType.hosted, name);
assertThat(calculation.getRuleName(), equalTo("0001-simple-rule"));
assertThat(calculation.getSupplementalStores().isEmpty(), equalTo(true));
final HostedRepository remote = (HostedRepository) calculation.getStore();
assertThat(remote.isAllowReleases(), equalTo(true));
assertThat(remote.isAllowSnapshots(), equalTo(true));
}
use of org.commonjava.indy.autoprox.rest.dto.AutoProxCalculation in project indy by Commonjava.
the class CalculateGroupTest method calculate.
@Test
public void calculate() throws Exception {
final String name = "test";
final AutoProxCalculation calculation = module.calculateRuleOutput(StoreType.group, name);
assertThat(calculation.getRuleName(), equalTo("0001-simple-rule"));
final List<ArtifactStore> supplemental = calculation.getSupplementalStores();
assertThat(supplemental.size(), equalTo(4));
final Group store = (Group) calculation.getStore();
assertThat(store.getName(), equalTo(name));
int idx = 0;
ArtifactStore supp = supplemental.get(idx);
assertThat(supp.getName(), equalTo(name));
assertThat(supp instanceof HostedRepository, equalTo(true));
final HostedRepository hosted = (HostedRepository) supp;
assertThat(hosted.isAllowReleases(), equalTo(true));
assertThat(hosted.isAllowSnapshots(), equalTo(true));
idx++;
supp = supplemental.get(idx);
assertThat(supp.getName(), equalTo(name));
assertThat(supp instanceof RemoteRepository, equalTo(true));
final RemoteRepository remote = (RemoteRepository) supp;
assertThat(remote.getUrl(), equalTo("http://localhost:1000/target/" + name));
}
use of org.commonjava.indy.autoprox.rest.dto.AutoProxCalculation in project indy by Commonjava.
the class CalculateRemoteRepoTest method calculate.
@Test
public void calculate() throws Exception {
final String name = "test";
final AutoProxCalculation calculation = module.calculateRuleOutput(StoreType.remote, name);
assertThat(calculation.getRuleName(), equalTo("0001-simple-rule"));
assertThat(calculation.getSupplementalStores().isEmpty(), equalTo(true));
final RemoteRepository remote = (RemoteRepository) calculation.getStore();
assertThat(remote.getUrl(), equalTo("http://localhost:1000/target/" + name));
}
Aggregations