Esempio n. 1
0
  @Test
  public void testCreate() throws SQLException {
    // Test data
    String name = "TEST_RETROSPECTIVE_NAME";
    String description = "TEST_RETROSPECTIVE_DESCRIPTION";
    String type = RetrospectiveObject.TYPE_GOOD;
    String status = RetrospectiveObject.STATUS_NEW;
    long sprintId = 1;

    // Create Retrospective
    RetrospectiveObject retrospective = new RetrospectiveObject(mProject.getId());
    retrospective
        .setName(name)
        .setDescription(description)
        .setType(type)
        .setStatus(status)
        .setSprintId(sprintId);

    // Test create method
    long retrospectiveId = RetrospectiveDAO.getInstance().create(retrospective);
    assertTrue(retrospectiveId > 0);

    // Get Data From DB
    IQueryValueSet valueSet = new MySQLQuerySet();
    valueSet.addTableName(RetrospectiveEnum.TABLE_NAME);
    valueSet.addEqualCondition(RetrospectiveEnum.ID, retrospectiveId);

    String query = valueSet.getSelectQuery();
    ResultSet result = mControl.executeQuery(query);

    RetrospectiveObject retrospectiveFromDB = null;

    if (result.next()) {
      retrospectiveFromDB = RetrospectiveDAO.convert(result);
    }
    closeResultSet(result);

    // Verify Data
    assertEquals(name, retrospectiveFromDB.getName());
    assertEquals(description, retrospectiveFromDB.getDescription());
    assertEquals(type, retrospectiveFromDB.getType());
    assertEquals(status, retrospectiveFromDB.getStatus());
    assertEquals(sprintId, retrospectiveFromDB.getSprintId());
  }
Esempio n. 2
0
  @Test
  public void testDelete() throws SQLException {
    // Call DAO delete
    boolean isDeleteSuccess = RetrospectiveDAO.getInstance().delete(mRtrospectiveId);
    assertTrue(isDeleteSuccess);

    // Fetch Retrospective from DB
    IQueryValueSet valueSet = new MySQLQuerySet();
    valueSet.addTableName(RetrospectiveEnum.TABLE_NAME);
    valueSet.addEqualCondition(RetrospectiveEnum.ID, mRtrospectiveId);

    String query = valueSet.getSelectQuery();
    ResultSet result = mControl.executeQuery(query);
    RetrospectiveObject retrospectiveFromDB = null;

    if (result.next()) {
      retrospectiveFromDB = RetrospectiveDAO.convert(result);
    }
    closeResultSet(result);

    // assert
    assertNull(retrospectiveFromDB);
  }