Skip to content

Commit

Permalink
Merge pull request #71 from hycomsa/70
Browse files Browse the repository at this point in the history
Add searching by id and name #70
  • Loading branch information
kulasekp authored Nov 9, 2019
2 parents 0cb0c53 + 41903b9 commit 06b2dd7
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ addons:
before_install:
- cd src
script:
- mvn test org.jacoco:jacoco-maven-plugin:prepare-agent sonar:sonar
- mvn verify # org.jacoco:jacoco-maven-plugin:prepare-agent
cache:
directories:
- "$HOME/.m2/repository"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,16 @@ public WrappedMockConfiguration getMockConfigurations(HttpServletRequest req) {
mockSearch.setMaxResults(numberOfResultsPerQuery);
}

// id
if (StringUtils.isNotBlank(req.getParameter(MockSearch.ID))) {
mockSearch.add(MockSearch.ID, req.getParameter(MockSearch.ID));
}

// name
if (StringUtils.isNotBlank(req.getParameter(MockSearch.NAME))) {
mockSearch.add(MockSearch.NAME, req.getParameter(MockSearch.NAME));
}

// path
if (StringUtils.isNotBlank(req.getParameter(MockSearch.PATH))) {
mockSearch.add(MockSearch.PATH, req.getParameter(MockSearch.PATH));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
@Transactional
public class MockSearch {

public static final String ID = "id";
public static final String NAME = "name";
public static final String PATH = "path";
public static final String DESCRIPTION = "description";
public static final String PATTERN = "pattern";
Expand All @@ -43,8 +45,24 @@ public List<MockConfiguration> find(){
base.append("select m from MockConfig m where ");
}

if(parameterMap.containsKey(ID)) {
base.append("m.id = :id ");
}

if(parameterMap.containsKey(NAME)) {
if(base.toString().endsWith(WHERE)) {
base.append("lower(m.name) like lower(:name) ");
} else {
base.append("and lower(m.name) like lower(:name) ");
}
}

if(parameterMap.containsKey(PATH)) {
base.append("lower(m.path) like lower(:path) ");
if(base.toString().endsWith(WHERE)) {
base.append("lower(m.path) like lower(:path) ");
}else {
base.append("and lower(m.path) like lower(:path) ");
}
}

if(parameterMap.containsKey(PATTERN)){
Expand Down Expand Up @@ -85,6 +103,14 @@ public List<MockConfiguration> find(){

query = em.createQuery(base.toString(), MockConfiguration.class);

if(parameterMap.containsKey(ID)) {
query.setParameter("id", Long.valueOf(parameterMap.get(ID)));
}

if(parameterMap.containsKey(NAME)) {
query.setParameter("name", PERCENT + parameterMap.get(NAME) + PERCENT);
}

if(parameterMap.containsKey(PATH)) {
query.setParameter("path", PERCENT + parameterMap.get(PATH) + PERCENT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ app.controller('ConfigurationController', function($rootScope, $scope, $mdToast,
self.mocks=[];
self.statuses=[101,201,202,203,204,205,206,02012,207,108,109,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30];
self.search = {};
self.search.enabled = true;
self.activeSearch = {};
self.pagination = 0;
self.paginationHasNext = false;
Expand Down Expand Up @@ -122,6 +123,7 @@ app.controller('ConfigurationController', function($rootScope, $scope, $mdToast,
var newMock = {};
newMock.editMode = true;
newMock.isNew = true;
newMock.status = "200";

self.mocks.unshift(newMock)
}
Expand Down
49 changes: 33 additions & 16 deletions src/mokka/src/main/resources/templates/configuration/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,38 @@
<md-card-content ng-filter="ctrl.activateFilter();ctrl.getPaths()">
<md-content layout-padding="" layout="column">
<div layout="row">
<md-input-container class="md-block" flex="33">
<md-input-container class="md-block" flex="10">
<label>Id</label>
<input ng-model="ctrl.search.id" ng-change="ctrl.search.update = true" type="number"
ng-enter="ctrl.activateFilter()"/>
</md-input-container>
<md-input-container class="md-block" flex="45">
<label>Service</label>
<md-select ng-model="ctrl.search.path" ng-click="ctrl.getPaths()"
ng-enter="ctrl.activateFilter();ctrl.getPaths()">
<md-option value="">All</md-option>
<md-option ng-repeat="path in ctrl.paths" value="{{path}}">{{path}}</md-option>
</md-select>
</md-input-container>
<md-input-container class="md-block" flex="33">
<md-input-container class="md-block" flex="45">
<label>Name</label>
<input ng-model="ctrl.search.name" ng-change="ctrl.search.update = true"
ng-enter="ctrl.activateFilter()"/>
</md-input-container>
</div>

<div layout="row">
<md-input-container class="md-block" flex="40">
<label>Pattern</label>
<input ng-model="ctrl.search.pattern" ng-change="ctrl.search.update = true"
ng-enter="ctrl.activateFilter()"/>
</md-input-container>
<md-input-container class="md-block" flex="33">
<md-input-container class="md-block" flex="45">
<label>Description</label>
<input ng-model="ctrl.search.description" ng-change="ctrl.search.update = true"
ng-enter="ctrl.activateFilter()"/>
</md-input-container>
</div>
<div layout="row">
<md-input-container class="md-block" flex="33" ng-enter="ctrl.activateFilter()">
<md-input-container class="md-block" flex="15" ng-enter="ctrl.activateFilter()">
<label>Status</label>
<md-select ng-model="ctrl.search.enabled" ng-change="ctrl.search.update = true"
ng-enter="ctrl.activateFilter()">
Expand All @@ -68,10 +79,11 @@
<md-option value="false">Disabled</md-option>
</md-select>
</md-input-container>

</div>
<div layout-gt-xs="row">
<md-button class="md-raised md-primary" ng-click="ctrl.getPaths();ctrl.activateFilter()">{{
ctrl.search.update ? 'Update results (F2)' : 'Filter (F2)' }}
ctrl.search.update ? 'Update results' : 'Filter' }}
</md-button>
<md-button class="md-raised" ng-click="ctrl.getPaths();ctrl.resetFilter()">Reset</md-button>
</div>
Expand All @@ -91,17 +103,27 @@ <h3>No mocks were found</h3>

<div class="mock-basic">
<div layout="row" layout-align="start center">
<md-input-container md-is-error="mock.errors.path != null" flex="50">
<label>Path</label>
<md-input-container md-is-error="mock.errors.id != null" flex="5" ng-hide="mock.id == null">
<label>Id</label>
<input placeholder="" ng-model="mock.id" required="" ng-disabled="true"
md-no-asterisk="true" ng-enter="ctrl.saveEditMode(mock)"/>
</md-input-container>
<md-input-container md-is-error="mock.errors.path != null" flex="40">
<label>Service</label>
<input placeholder="" ng-model="mock.path" required="" ng-disabled="!mock.editMode"
md-no-asterisk="true" ng-enter="ctrl.saveEditMode(mock)"/>
</md-input-container>
<md-input-container md-is-error="mock.errors.timeout != null" flex="25">
<md-input-container md-is-error="mock.errors.name != null" flex="40">
<label>Name</label>
<input placeholder="" ng-model="mock.name" ng-disabled="!mock.editMode"
ng-enter="ctrl.saveEditMode(mock)"/>
</md-input-container>
<md-input-container md-is-error="mock.errors.timeout != null" flex="10">
<label>Delay (ms)</label>
<input type="number" placeholder="" ng-model="mock.timeout" ng-disabled="!mock.editMode"
ng-enter="ctrl.saveEditMode(mock)"/>
</md-input-container>
<md-input-container md-is-error="mock.errors.order != null" flex="25">
<md-input-container md-is-error="mock.errors.order != null" flex="5">
<label>Order</label>
<input type="number" placeholder="" ng-model="mock.order" ng-disabled="!mock.editMode"
ng-enter="ctrl.saveEditMode(mock)"/>
Expand All @@ -112,11 +134,6 @@ <h3>No mocks were found</h3>
<input placeholder="" ng-model="mock.pattern" ng-disabled="!mock.editMode"
ng-enter="ctrl.saveEditMode(mock)"/>
</md-input-container>
<md-input-container class="full-width" md-is-error="mock.errors.name != null">
<label>Name</label>
<input placeholder="" ng-model="mock.name" ng-disabled="!mock.editMode"
ng-enter="ctrl.saveEditMode(mock)"/>
</md-input-container>
<md-input-container class="full-width" md-is-error="mock.errors.description != null">
<label>Description</label>
<textarea placeholder="" ng-model="mock.description" ng-disabled="!mock.editMode"
Expand Down
3 changes: 3 additions & 0 deletions src/mokka/src/main/resources/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ <h2>
<md-menu-item th:if="${path != 'configuration'}">
<md-button th:href="@{/configurations}" target="_self">Configuration</md-button>
</md-menu-item>
<!-- <md-menu-item th:if="${path != 'jmsconfiguration'}">-->
<!-- <md-button th:href="@{/jmsconfigurations}" target="_self">Jms Mock Configuration</md-button>-->
<!-- </md-menu-item>-->
<md-menu-item th:if="${path != 'model'}" sec:authorize="hasAnyRole('ROLE_ADMIN', 'ROLE_EDITOR')">
<md-button th:href="@{/models}" target="_self">Model</md-button>
</md-menu-item>
Expand Down
29 changes: 20 additions & 9 deletions src/mokka/src/main/resources/templates/jmsconfiguration/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ <h4>{{ctrl.greeting}}</h4>
<md-card-content>
<md-content layout-padding="" layout="column">
<div layout="row">
<md-input-container class="md-block" flex="15">
<label>Id</label>
<input ng-model="ctrl.search.id" ng-change="ctrl.search.update = true" type="number"
ng-enter="ctrl.activateFilter()"/>
</md-input-container>
<md-input-container class="md-block" flex="33">
<label>Name</label>
<input ng-model="ctrl.search.name" ng-change="ctrl.search.update = true"/>
Expand All @@ -46,24 +51,25 @@ <h4>{{ctrl.greeting}}</h4>
<input ng-model="ctrl.search.queueName" ng-change="ctrl.search.update = true"/>
</md-input-container>

</div>

<div layout="row">
<md-input-container class="md-block" flex="33">
<label>Pattern(body)</label>
<input ng-model="ctrl.search.pattern" ng-change="ctrl.search.update = true"/>
</md-input-container>
</div>
<div layout="row">
<md-input-container class="md-block" flex="33">
<label>Description</label>
<input ng-model="ctrl.search.description" ng-change="ctrl.search.update = true"/>
</md-input-container>
<md-input-container class="md-block" flex="15">
<label>Status</label>
<md-select ng-model="ctrl.search.enabled" ng-change="ctrl.search.update = true">
<md-option value="">All</md-option>
<md-option value="true">Enabled</md-option>
<md-option value="false">Disabled</md-option>
</md-select>
</md-input-container>
<md-input-container class="md-block" flex="33">
<label>Description</label>
<input ng-model="ctrl.search.description" ng-change="ctrl.search.update = true"/>
</md-input-container>
</div>
<div layout-gt-xs="row">
<md-button class="md-raised md-primary" ng-click="ctrl.activateFilter()">Filter</md-button>
Expand Down Expand Up @@ -92,15 +98,20 @@ <h3>No mocks were found</h3>

<div class="jmsmock-basic">
<div layout="row" layout-align="start center">
<md-input-container md-is-error="jmsmock.errors.path != null" flex="50">
<md-input-container md-is-error="jmsmock.errors.id != null" flex="5">
<label>Id</label>
<input placeholder="" ng-model="jmsmock.id" required="" ng-disabled="true"
md-no-asterisk="true" ng-enter="ctrl.saveEditMode(mock)"/>
</md-input-container>
<md-input-container md-is-error="jmsmock.errors.path != null" flex="60">
<label>Request Queue Name</label>
<input placeholder="" ng-model="jmsmock.requestQueueName" required="" ng-disabled="!jmsmock.editMode" md-no-asterisk="true"/>
</md-input-container>
<md-input-container md-is-error="jmsmock.timeout != null" flex="25">
<md-input-container md-is-error="jmsmock.timeout != null" flex="20">
<label>Delay (ms)</label>
<input type="number" placeholder="" ng-model="jmsmock.timeout" ng-disabled="!jmsmock.editMode"/>
</md-input-container>
<md-input-container md-is-error="jmsmock.errors.order != null" flex="25">
<md-input-container md-is-error="jmsmock.errors.order != null" flex="20">
<label>Order</label>
<input type="number" placeholder="" ng-model="jmsmock.order" ng-disabled="!jmsmock.editMode"/>
</md-input-container>
Expand Down

0 comments on commit 06b2dd7

Please sign in to comment.