Skip to content

Commit

Permalink
Added testcase search.
Browse files Browse the repository at this point in the history
  • Loading branch information
gitorko committed Feb 19, 2016
1 parent 9ae42d9 commit 57fe5dd
Show file tree
Hide file tree
Showing 10 changed files with 153 additions and 27 deletions.
4 changes: 0 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
</properties>
<name>excord</name>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/deem/excord/controller/TestCaseController.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ public class TestCaseController {
@Autowired
HistoryUtil historyUtil;

@RequestMapping(value = {"/search"}, method = RequestMethod.GET)
public String search(HttpSession session, Model model) {
return "search";
}

@RequestMapping(value = {"/search"}, method = RequestMethod.POST)
public String searchKey(HttpSession session, Model model, @RequestParam(value = "searchKey", required = true) String searchKey) {
LOGGER.info("Search key: {}", searchKey);
List<EcTestcase> testCaseLst = tcDao.searchTestcase(searchKey);
model.addAttribute("searchKey", searchKey);
model.addAttribute("testCaseLst", testCaseLst);
return "search";
}

@RequestMapping(value = "/testcase", method = RequestMethod.GET)
public String testCases(Model model, HttpSession session, @RequestParam(value = "nodeId", required = false, defaultValue = "1") Long nodeId) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ public String activeTestplan(HttpSession session, Model model) {
testPlanLst = tpDao.findByEnabledOrderByIdDesc(true);
List<Object[]> metricsLst = tpDao.findMetrics();
List<TestPlanMetricVo> testPlanMetricsLst = BizUtil.INSTANCE.gererateAllTestPlanMetrics(testPlanLst, metricsLst);
model.addAttribute("home", "yes");
model.addAttribute("testPlanMetricsLst", testPlanMetricsLst);
model.addAttribute("testPlanLst", testPlanLst);
return "testplan";
return "testplan_active";
}

@RequestMapping(value = {"/testplan"}, method = RequestMethod.GET)
Expand Down Expand Up @@ -243,7 +242,7 @@ public String saveTestPlan(HttpSession session, Model model, HttpServletRequest
historyUtil.addHistory("Added/Updated testplan: [" + tname + "]", tp.getSlug(), request, session);
session.setAttribute("flashMsg", "Successfully Saved TestPlan " + tp.getName());

return "redirect:/testplan";
return "redirect:/testplan_active";
} catch (Exception ex) {
LOGGER.error(ex.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ public interface TestCaseRepository extends CrudRepository<EcTestcase, Long> {
@Query(value = "SELECT count(*) FROM ec_testcase where enabled = 1", nativeQuery = true)
public Integer getCountOfActiveTestcases();

@Query(value = "select * from ec_testcase where `name` like CONCAT('%',:searchKey,'%') or `description` like CONCAT('%',:searchKey,'%') order by id desc", nativeQuery = true)
public List<EcTestcase> searchTestcase(@Param("searchKey") String searchKey);

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ 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);

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</Pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOG_FILE}.%d{yyyy-MM-dd}.log</fileNamePattern>
<fileNamePattern>${LOG_PATH}/${LOG_FILE}.%d{yyyy-MM-dd}.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/templates/common/menubar.ftl.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<li><a href="/report_coverage">Requirements Missing Coverage</a></li>
</ul>
</li>
<li><a href="/search">Search</a></li>
<li><a href="/history">History</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
Expand Down
61 changes: 61 additions & 0 deletions src/main/resources/templates/search.ftl.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<#import "layouts/main-layout.ftl.html" as main>
<@main.page>
<div class="container-fluid">
<form method="post" action="/search" role="form" class="form-horizontal">
<div class="row">
<div class="col-md-12 text-center">
<h3>Search Testcase</h3>
<br/>
</div>
</div>
<div class="form-group">
<div class="col-md-8">
<input type="text" name="searchKey" value="<#if searchKey??>${searchKey}</#if>" class="form-control" placeholder="Search Testcase Name Or Description" required>
</div>
<div class="col-md-4">
<button type="submit" name="action" value="searchtestcase" class="btn btn-primary btn-block">Search Testcase</button>
</div>
<br/>
<br/>
<br/>
</div>

<#if testCaseLst??>
<div class="row">
<div class="col-md-12">
<table id="testcase-ele" class="table table-striped table-bordered" width="100%" cellspacing="0">
<thead>
<tr>
<th>Testcase ID</th>
<th>Test Folder</th>
<th>Test Name</th>
<th>Product</th>
</tr>
</thead>
<tbody>
<#list testCaseLst as tc>
<tr>
<td>
${tc.id?c}
</td>
<td>
<a href="/testcase?nodeId=${tc.folderId.id?c}">
${tc.folderId.name}
</a>
</td>
<td><a href="/testcase_edit?testcaseId=${tc.id?c}">${tc.name}</a></td>
<td>
${tc.product}
</td>
</tr>
</#list>

</tbody>
</table>
<br/>
</div>
</div>
</#if>
</form>
</div>
</@main.page>
19 changes: 1 addition & 18 deletions src/main/resources/templates/testplan.ftl.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,12 @@
<div class="container-fluid">
<div class="row">
<div class="col-md-12 left">
<#if home??>
<h3>Active Test Plans</h3>
<#assign tableElement = "testplan"/>
<#else>
<h3>All Test Plans</h3>
<#assign tableElement = "testplan-ele"/>
</#if>
<br/>
</div>
</div>

<table id="${tableElement}" class="table table-striped table-bordered" width="100%" cellspacing="0">
<table id="testplan-ele" class="table table-striped table-bordered" width="100%" cellspacing="0">
<thead>
<tr>
<th>ID</th>
Expand Down Expand Up @@ -64,16 +58,5 @@ <h3>All Test Plans</h3>
</tbody>
</table>

<#if home??>
<#else>
<div class="row">
<div class="col-md-12 text-center">
<br/>
<br/>
<a href="/testplan_add" title="Add Test Step" class="btn btn-info" ><i class="fa fa-plus-square"></i> &nbsp; Add Test Plan</a>
</div>
</div>
</#if>
<br/>
</div>
</@main.page>
69 changes: 69 additions & 0 deletions src/main/resources/templates/testplan_active.ftl.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<#import "layouts/main-layout.ftl.html" as main>
<@main.page>

<div class="container-fluid">
<div class="row">
<div class="col-md-12 left">
<h3>Active Test Plans</h3>
<br/>
</div>
</div>

<table class="table table-striped table-bordered" width="100%" cellspacing="0">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Enabled</th>
<th>Release</th>
<th>Schedule</th>
<th>Leader</th>
<th>Start date</th>
<th>End Date</th>
<th>Pass Rate</th>
<th>Progress Rate</th>
</tr>
</thead>

<tbody>
<#list testPlanLst as testPlan>
<tr>
<td>${testPlan.id}</td>
<td><a href="/testplan_view?testplanId=${testPlan.id?c}">${testPlan.name}</a></td>
<td>${testPlan.enabled?c}</td>
<td><#if testPlan.releaseName??>${testPlan.releaseName}</#if></td>
<td><#if testPlan.schedule??>${testPlan.schedule}</#if></td>
<td><#if testPlan.leader??>${testPlan.leader}</#if></td>
<td><#if testPlan.startDate??>${testPlan.startDate}</#if></td>
<td><#if testPlan.endDate??>${testPlan.endDate}</#if></td>
<td>
<#list testPlanMetricsLst as tpm>
<#if tpm.testPlanId == testPlan.id>
${tpm.passRate}%
</#if>
</#list>
</td>
<td>
<#list testPlanMetricsLst as tpm>
<#if tpm.testPlanId == testPlan.id>
${tpm.progressRate}%
</#if>
</#list>
</td>

</tr>
</#list>

</tbody>
</table>

<div class="row">
<div class="col-md-12 text-center">
<br/>
<br/>
<a href="/testplan_add" title="Add Test Step" class="btn btn-info" ><i class="fa fa-plus-square"></i> &nbsp; Add Test Plan</a>
</div>
</div>
<br/>
</div>
</@main.page>

0 comments on commit 57fe5dd

Please sign in to comment.