use of io.fabric8.internal.ContainerImpl in project fabric8 by jboss-fuse.
the class FabricServiceImpl method getContainers.
@Override
public Container[] getContainers() {
assertValid();
Map<String, Container> containers = new HashMap<String, Container>();
List<String> containerIds = dataStore.get().getContainers();
for (String containerId : containerIds) {
String parentId = dataStore.get().getContainerParent(containerId);
if (parentId.isEmpty()) {
if (!containers.containsKey(containerId)) {
Container container = new ContainerImpl(null, containerId, this);
containers.put(containerId, container);
}
} else {
Container parent = containers.get(parentId);
if (parent == null) {
parent = new ContainerImpl(null, parentId, this);
containers.put(parentId, parent);
}
Container container = new ContainerImpl(parent, containerId, this);
containers.put(containerId, container);
}
}
return containers.values().toArray(new Container[containers.size()]);
}
use of io.fabric8.internal.ContainerImpl in project fabric8 by jboss-fuse.
the class ContainerImplTest method setUp.
@Before
public void setUp() {
fabricService = createMock(FabricService.class);
dataStore = createMock(DataStore.class);
expect(fabricService.adapt(DataStore.class)).andReturn(dataStore).anyTimes();
container = new ContainerImpl(null, CONTAINER_ID, fabricService);
}
use of io.fabric8.internal.ContainerImpl in project fabric8 by jboss-fuse.
the class ContainerPlaceholderResolverTest method testResolveCurrentName.
@Test
@Ignore("[FABRIC-1110] Mocked test makes invalid assumption on the implementation")
public void testResolveCurrentName() throws Exception {
final FabricService fabricService = createMock(FabricService.class);
final DataStore dataStore = createMock(DataStore.class);
expect(fabricService.getCurrentContainerName()).andReturn("root").anyTimes();
expect(fabricService.getContainer(EasyMock.<String>anyObject())).andReturn(new ContainerImpl(null, "root", fabricService));
replay(fabricService);
replay(dataStore);
PlaceholderResolver resolver = getContainerPlaceholderResolver();
assertEquals("root", resolver.resolve(fabricService, null, null, null, "container:name"));
verify(fabricService);
verify(dataStore);
}
use of io.fabric8.internal.ContainerImpl in project fabric8 by jboss-fuse.
the class FabricServiceImpl method getContainer.
@Override
public Container getContainer(String name) {
assertValid();
if (dataStore.get().hasContainer(name)) {
Container parent = null;
String parentId = dataStore.get().getContainerParent(name);
if (parentId != null && !parentId.isEmpty()) {
parent = getContainer(parentId);
}
return new ContainerImpl(parent, name, this);
}
throw new FabricException("Container '" + name + "' does not exist");
}
use of io.fabric8.internal.ContainerImpl in project fabric8 by jboss-fuse.
the class ContainerLifecycleCommandsTest method testStopSingleContainer.
@Test
public void testStopSingleContainer() throws Exception {
containers("c1");
ContainerImpl c1 = newContainer("c1");
expect(this.fabricService.adapt(CuratorFramework.class)).andReturn(this.curatorFramework).anyTimes();
expect(this.fabricService.getContainers()).andReturn(new Container[] { c1 });
this.fabricService.stopContainer(c1, false);
replay(this.fabricService, this.commandSession);
this.stop.execute(this.commandSession);
verify(this.fabricService);
}
Aggregations