@Override public void removeCube(String id) { CubeId cubeId = CubeIdFactory.get().create(id); if (cubeId instanceof StarredCubeId) { throw new IllegalArgumentException("Starred cube id cannot be removed."); } cubes.remove(cubeId); }
@Override public void removeCube(String id) { CubeId cubeId = CubeIdFactory.get().create(id); if (cubeId instanceof StarredCubeId) { throw new IllegalArgumentException("Starred cube id cannot be removed."); } cubes.remove(cubeId); }
@Override public Cube<?> getCube(String id) { CubeId cubeId = CubeIdFactory.get().create(id); for (Map.Entry<CubeId, Cube<?>> cubeEntry : this.cubes.entrySet()) { CubeId internalCubeId = cubeEntry.getKey(); if (internalCubeId.isMatching(cubeId)) { return cubeEntry.getValue(); } } return null; }
@Override public void addCube(Cube<?> cube) { CubeId cubeId = CubeIdFactory.get().create(cube.getId()); if (cubeId instanceof StarredCubeId) { throw new IllegalArgumentException("Starred cube id cannot be added."); } this.cubes.put(cubeId, cube); }
@Override public Cube<?> getCube(String id) { CubeId cubeId = CubeIdFactory.get().create(id); for (Map.Entry<CubeId, Cube<?>> cubeEntry : this.cubes.entrySet()) { CubeId internalCubeId = cubeEntry.getKey(); if (internalCubeId.isMatching(cubeId)) { return cubeEntry.getValue(); } } return null; }
@Override public void addCube(Cube<?> cube) { CubeId cubeId = CubeIdFactory.get().create(cube.getId()); if (cubeId instanceof StarredCubeId) { throw new IllegalArgumentException("Starred cube id cannot be added."); } this.cubes.put(cubeId, cube); }
@Test(expected = NullPointerException.class) public void shouldThrowNPEOnNull() throws Exception { CubeIdFactory.get().create(null); }
@Test public void shouldCreateDefaultCubeId() throws Exception { CubeId cubeId = CubeIdFactory.get().create("tomcat"); Assert.assertTrue(cubeId instanceof DefaultCubeId); } }
@Test public void shouldCreateStarredCubeId() throws Exception { CubeId cubeId = CubeIdFactory.get().create("tomcat*"); Assert.assertTrue(cubeId instanceof StarredCubeId); }
@Test public void shouldCreateParallelizedCubeId() throws Exception { CubeId cubeId = CubeIdFactory.get().create("tomcat_46fd2cc1-0084-42a8-9ffd-35f305a08dcc"); Assert.assertTrue(cubeId instanceof ParallelizedCubeId); }