예제 #1
0
  @Test(dependsOnMethods = "shouldGetById")
  public void shouldUpdateStack() throws Exception {
    final StackImpl stack = stacks[0];

    stack.setName("new-name");
    stack.setCreator("new-creator");
    stack.setDescription("new-description");
    stack.setScope("new-scope");
    stack.getTags().clear();
    stack.getTags().add("new-tag");

    // Remove an existing component
    stack.getComponents().remove(1);

    // Add a new component
    stack.getComponents().add(new StackComponentImpl("component3", "component3-version"));

    // Update an existing component
    final StackComponentImpl component = stack.getComponents().get(0);
    component.setName("new-name");
    component.setVersion("new-version");

    // Updating source
    final StackSourceImpl source = stack.getSource();
    source.setType("new-type");
    source.setOrigin("new-source");

    // Set a new icon
    stack.setStackIcon(new StackIcon("new-name", "new-media", "new-data".getBytes()));

    stackDao.update(stack);

    assertEquals(stackDao.getById(stack.getId()), new StackImpl(stack));
  }
예제 #2
0
  @Test(dependsOnMethods = "shouldGetById")
  public void shouldCreateStack() throws Exception {
    final StackImpl stack = createStack("new-stack", "new-stack-name");

    stackDao.create(stack);

    assertEquals(stackDao.getById(stack.getId()), stack);
  }
예제 #3
0
  @Test(
      expectedExceptions = NotFoundException.class,
      dependsOnMethods = "shouldThrowNotFoundExceptionWhenGettingNonExistingStack")
  public void shouldRemoveStack() throws Exception {
    final StackImpl stack = stacks[0];

    stackDao.remove(stack.getId());

    // Should throw an exception
    stackDao.getById(stack.getId());
  }
예제 #4
0
 @Test(expectedExceptions = NullPointerException.class)
 public void shouldThrowNpeWhenGettingStackByNullKey() throws Exception {
   stackDao.getById(null);
 }
예제 #5
0
 @Test(expectedExceptions = NotFoundException.class)
 public void shouldThrowNotFoundExceptionWhenGettingNonExistingStack() throws Exception {
   stackDao.getById("non-existing-stack");
 }
예제 #6
0
  @Test
  public void shouldGetById() throws Exception {
    final StackImpl stack = stacks[0];

    assertEquals(stackDao.getById(stack.getId()), stack);
  }