Skip to content

Commit

Permalink
Making product mandatory + Breakup by product
Browse files Browse the repository at this point in the history
  • Loading branch information
gitorko committed Feb 11, 2016
1 parent ca99e1c commit fb4b90c
Show file tree
Hide file tree
Showing 9 changed files with 200 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.deem.excord.repository.TestPlanRepository;
import com.deem.excord.repository.TestResultRepository;
import com.deem.excord.repository.TestcaseRequirementRepository;
import com.deem.excord.util.BizUtil;
import com.deem.excord.vo.TestPlanMetricVo;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -48,6 +50,9 @@ public String reportExecution(Model model) {
@RequestMapping(value = "/testplan_metric", method = RequestMethod.GET)
public String testplanMetric(Model model, @RequestParam(value = "testplanId", required = true) Long testplanId) {
List<Object[]> metricLst = tpDao.findByPriorityByTester(testplanId);
List<Object[]> tmLst = tpDao.findProductMetricsByTestplanId(testplanId);
List<TestPlanMetricVo> testPlanMetricLst = BizUtil.INSTANCE.flattenTestPlanMetricsByProduct(tmLst);
model.addAttribute("testPlanMetricLst", testPlanMetricLst);
model.addAttribute("metricLst", metricLst);
return "testplan_metric";
}
Expand Down
133 changes: 68 additions & 65 deletions src/main/java/com/deem/excord/controller/TestCaseController.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public String viewTestPlan(Model model, HttpSession session, @RequestParam(value
EcTestplan testPlan = tpDao.findOne(testplanId);
List<EcTestplanTestcaseMapping> tptcLst = tptcDao.findByTestplanId(testPlan);
List<Object[]> tmLst = tpDao.findMetricsByTestplanId(testplanId);
List<TestPlanMetricVo> testPlanMetricLst = BizUtil.INSTANCE.flattenTestPlanMetrics(tmLst);
List<TestPlanMetricVo> testPlanMetricLst = BizUtil.INSTANCE.flattenTestPlanMetricsByFolder(tmLst);
Integer totalPassCount = 0;
Integer totalCount = 0;
Integer totalNotRunCount = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public interface TestPlanRepository extends CrudRepository<EcTestplan, Long> {

@Query(value = "select testfolder_id,testcase_folder,test_status ,count(*) from (select c.id testplan_testcase_link_id,a.id testcase_id,a.name testcase_name,b.id testfolder_id,b.name testcase_folder,d.status test_status,d.latest from ec_testcase a,ec_testfolder b,ec_testplan_testcase_mapping c LEFT JOIN ec_testresult d ON d.testplan_testcase_link_id = c.id where a.folder_id = b.id and a.id = c.testcase_id and c.testplan_id = :testplanId) e where e.latest is null or e.latest = 1 group by testcase_folder,test_status", nativeQuery = true)
public List<Object[]> findMetricsByTestplanId(@Param("testplanId") Long testplanId);

@Query(value = "select product,`status`,count(*) from ec_testcase a,ec_testplan_testcase_mapping b LEFT JOIN ec_testresult c ON c.testplan_testcase_link_id = b.id where a.id = b.testcase_id and b.testplan_id = :testplanId and (latest is null or latest = 1 ) group by product,`status`", nativeQuery = true)
public List<Object[]> findProductMetricsByTestplanId(@Param("testplanId") Long testplanId);

@Query(value = "select b.testplan_id,a.`status`,count(*) as count from ec_testresult a ,ec_testplan_testcase_mapping b where a.testplan_testcase_link_id = b.id and a.latest =1 and a.`status` = 'NOT_RUN' group by a.`status`,b.testplan_id UNION ALL select b.testplan_id,a.`status`,count(*) as count from ec_testresult a ,ec_testplan_testcase_mapping b where a.testplan_testcase_link_id = b.id and a.latest =1 and a.`status` = 'PASSED' group by a.`status`,b.testplan_id UNION ALL select testplan_id,'TOTAL', count(*) count from ec_testplan_testcase_mapping group by testplan_id UNION ALL select b.testplan_id,'RUN',count(*) as count from ec_testresult a ,ec_testplan_testcase_mapping b where a.testplan_testcase_link_id = b.id and a.latest =1 and a.status != 'NOT_RUN' group by b.testplan_id", nativeQuery = true)
public List<Object[]> findMetrics();
Expand Down
61 changes: 60 additions & 1 deletion src/main/java/com/deem/excord/util/BizUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public String getSlug() {
return UUID.randomUUID().toString();
}

public List<TestPlanMetricVo> flattenTestPlanMetrics(List<Object[]> tmLst) {
public List<TestPlanMetricVo> flattenTestPlanMetricsByFolder(List<Object[]> tmLst) {
Map<Long, TestPlanMetricVo> tmMap = new HashMap<Long, TestPlanMetricVo>();
for (Object[] result : tmLst) {
Long folderId = ((BigInteger) result[0]).longValue();
Expand Down Expand Up @@ -80,6 +80,65 @@ public List<TestPlanMetricVo> flattenTestPlanMetrics(List<Object[]> tmLst) {
return finalMetricLst;
}

public List<TestPlanMetricVo> flattenTestPlanMetricsByProduct(List<Object[]> tmLst) {
Map<String, TestPlanMetricVo> tmMap = new HashMap<String, TestPlanMetricVo>();
for (Object[] result : tmLst) {
String product = (String) result[0];
String status = (String) result[1];

if (status == null) {
status = Constants.STATUS_NOT_RUN;
}
TestPlanMetricVo tpm = tmMap.get(product);
if (tpm == null) {
tpm = new TestPlanMetricVo();
tpm.setProduct(product);
tpm.setPassCount(0);
tpm.setFailCount(0);
tpm.setNaCount(0);
tpm.setBlockedCount(0);
tpm.setFutureCount(0);
tpm.setNotcompleteCount(0);
tpm.setNotrunCount(0);
tpm.setTotal(0);
}

Integer count = 0;
if (result[2] != null) {
count = ((BigInteger) result[2]).intValue();
}
tpm.setTotal(tpm.getTotal() + count);
switch (status) {
case Constants.STATUS_PASSED:
tpm.setPassCount(count);
break;
case Constants.STATUS_FAILED:
tpm.setFailCount(count);
break;
case Constants.STATUS_BLOCKED:
tpm.setBlockedCount(count);
break;
case Constants.STATUS_NOT_COMPLETED:
tpm.setNotcompleteCount(count);
break;
default:
tpm.setNotrunCount(tpm.getNotrunCount() + count);
break;
}
tmMap.put(product, tpm);

}

List<TestPlanMetricVo> finalMetricLst = new ArrayList<TestPlanMetricVo>();
for (Map.Entry<String, TestPlanMetricVo> entry : tmMap.entrySet()) {
TestPlanMetricVo value = entry.getValue();
value.setPassRate(Math.round((value.getPassCount() * 100.0) / value.getTotal()));
value.setProgressRate(Math.round(((value.getTotal() - value.getNotrunCount()) * 100.0) / value.getTotal()));
finalMetricLst.add(value);
}
return finalMetricLst;
}

public List<TestPlanMetricVo> gererateTestplanMetrics(EcTestplan tp, List<Object[]> metricsLst) {
List<TestPlanMetricVo> resultLst = new ArrayList<TestPlanMetricVo>();
TestPlanMetricVo tpm = new TestPlanMetricVo();
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/deem/excord/vo/TestPlanMetricVo.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,16 @@ public class TestPlanMetricVo {
private Long passRate;
private Integer progressCount;
private Long progressRate;
private String product;

public String getProduct() {
return product;
}

public void setProduct(String product) {
this.product = product;
}

public Long getTestPlanId() {
return testPlanId;
}
Expand Down
11 changes: 7 additions & 4 deletions src/main/resources/templates/testcase_form.ftl.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ <h3>Test Case</h3>
<input type="hidden" name="tfolderId" value="${currentNode.id?c}"/>
<input type="text" name="tfolder" class="form-control" id="tfolder" value="${currentNode.name}" readonly>
</div>
<div class="form-group">
<label for="tproduct">Product</label><font color="red">*</font></label>
<input type="text" name="tproduct" class="form-control" id="tproduct" maxlength="45" required value="<#if tc??>${tc.product}</#if>"/>
</div>


<div class="form-group">
<label for="tlanguage">Language</label>
<input type="text" name="tlanguage" class="form-control" id="tlanguage" maxlength="45" value="<#if tc??>${tc.language}</#if>"/>
Expand All @@ -194,10 +200,7 @@ <h3>Test Case</h3>
<label for="tbugid">Bug Id</label>
<input name="tbugid" type="text" class="form-control" id="tbugid" maxlength="45" value="<#if tc??>${tc.bugId}</#if>"/>
</div>
<div class="form-group">
<label for="tproduct">Product</label>
<input type="text" name="tproduct" class="form-control" id="tproduct" maxlength="45" value="<#if tc??>${tc.product}</#if>"/>
</div>

<div class="form-group">
<label for="tfeature">Feature</label>
<input type="text" name="tfeature" class="form-control" id="tfeature" maxlength="45" value="<#if tc??>${tc.feature}</#if>"/>
Expand Down
44 changes: 42 additions & 2 deletions src/main/resources/templates/testplan_metric.ftl.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,43 @@
</div>
</div>
<br/><br/>
<div class="row">
<div class="col-md-12">
<table class="table table-striped table-bordered" width="100%" cellspacing="0">
<thead>
<tr>
<th colspan="9">Progress Report By Product</th>
</tr>
<tr>
<th>Product</th>
<th>PASSED</th>
<th>FAILED</th>
<th>BLOCKED</th>
<th>NOT_COMPLETED</th>
<th>NOT_RUN</th>
<th>Total</th>
<th>Pass Rate</th>
<th>Progress</th>
</tr>
</thead>
<tbody>
<#list testPlanMetricLst as tpm>
<tr>
<td>${tpm.product}</td>
<td>${tpm.passCount}</td>
<td>${tpm.failCount}</td>
<td>${tpm.blockedCount}</td>
<td>${tpm.notcompleteCount}</td>
<td>${tpm.notrunCount}</td>
<td>${tpm.total}</td>
<td>${tpm.passRate}%</td>
<td>${tpm.progressRate}%</td>
</tr>
</#list>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="col-md-12">
<table id="testmetric-ele" class="table table-striped table-bordered" width="100%" cellspacing="0">
Expand Down Expand Up @@ -45,11 +82,14 @@
</tr>

</#list>


</tbody>
</table>
</div>
</div>
<div class="row">
<div class="col-md-12 text-center">
<button type="button" name="action" id="back" value="back" class="btn btn-info" onclick="history.back()">Back</button>
</div>
</div>
</div>
</@main.page>
6 changes: 5 additions & 1 deletion src/main/resources/templates/testplan_view.ftl.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ <h3>Test Plan View</h3>
<tbody>
<#list testPlanMetricLst as tpm>
<tr>
<td>${tpm.folderName}</td>
<td><a href="/testcase?nodeId=${tpm.folderId?c}">${tpm.folderName}</a></td>
<td>${tpm.passCount}</td>
<td>${tpm.failCount}</td>
<td>${tpm.blockedCount}</td>
Expand Down Expand Up @@ -159,6 +159,7 @@ <h3>Test Plan View</h3>
<th>Testcase ID</th>
<th>Test Folder</th>
<th>Test Name</th>
<th>Product</th>
<th>Requirement</th>
<th>Testcase Priority</th>
<th>Assigned To</th>
Expand All @@ -180,6 +181,9 @@ <h3>Test Plan View</h3>
</a>
</td>
<td><a href="/testcase_edit?testcaseId=${tc.id?c}">${tc.name}</a></td>
<td>
${tc.product}
</td>
<td>
<#if tc.ecTestcaseRequirementMappingLst??>
<#list tc.ecTestcaseRequirementMappingLst as tcrMap>
Expand Down

0 comments on commit fb4b90c

Please sign in to comment.