use of io.fabric8.maven.docker.service.VolumeService in project docker-maven-plugin by fabric8io.
the class VolumeServiceTest method testCreateVolumeConfig.
@Test
public void testCreateVolumeConfig() throws Exception {
final VolumeConfiguration config = new VolumeConfiguration.Builder().name("testVolume").driver("test").opts(withMap("opts")).labels(withMap("labels")).build();
new Expectations() {
{
// Use a 'delegate' to verify the argument given directly. No need
// for an 'intermediate' return method in the service just to check this.
docker.createVolume(with(new Delegate<VolumeCreateConfig>() {
void check(VolumeCreateConfig vcc) {
assertThat(vcc.getName(), is("testVolume"));
JSONObject vccJson = (JSONObject) JSONParser.parseJSON(vcc.toJson());
assertEquals(vccJson.get("Driver"), "test");
}
}));
result = "testVolume";
}
};
String volume = new VolumeService(docker).createVolume(config);
assertEquals(volume, "testVolume");
}
use of io.fabric8.maven.docker.service.VolumeService in project docker-maven-plugin by fabric8io.
the class VolumeServiceTest method testRemoveVolume.
@Test
public void testRemoveVolume() throws Exception {
VolumeConfiguration vc = new VolumeConfiguration.Builder().name("testVolume").driver("test").opts(withMap("opts")).labels(withMap("labels")).build();
new Expectations() {
{
docker.createVolume((VolumeCreateConfig) any);
result = "testVolume";
docker.removeVolume("testVolume");
}
};
VolumeService volumeService = new VolumeService(docker);
String name = volumeService.createVolume(vc);
volumeService.removeVolume(name);
}
use of io.fabric8.maven.docker.service.VolumeService in project docker-maven-plugin by fabric8io.
the class VolumeServiceTest method testCreateVolume.
@Test
public void testCreateVolume() throws Exception {
VolumeConfiguration vc = new VolumeConfiguration.Builder().name("testVolume").driver("test").opts(withMap("opts")).labels(withMap("labels")).build();
new Expectations() {
{
docker.createVolume((VolumeCreateConfig) any);
result = "testVolume";
}
};
assertThat(vc.getName(), is("testVolume"));
String name = new VolumeService(docker).createVolume(vc);
assertThat(name, is("testVolume"));
}
use of io.fabric8.maven.docker.service.VolumeService in project docker-maven-plugin by fabric8io.
the class VolumeRemoveMojo method executeInternal.
@Override
protected void executeInternal(ServiceHub serviceHub) throws DockerAccessException, MojoExecutionException {
VolumeService volService = serviceHub.getVolumeService();
for (VolumeConfiguration volume : getVolumes()) {
log.info("Removing volume %s", volume.getName());
volService.removeVolume(volume.getName());
}
}
use of io.fabric8.maven.docker.service.VolumeService in project docker-maven-plugin by fabric8io.
the class VolumeCreateMojo method executeInternal.
@Override
protected void executeInternal(ServiceHub serviceHub) throws DockerAccessException, MojoExecutionException {
VolumeService volService = serviceHub.getVolumeService();
for (VolumeConfiguration volume : getVolumes()) {
log.info("Creating volume '%s'", volume.getName());
volService.createVolume(volume);
}
}
Aggregations