WireMock Standalone issue while using {{{pickRandom '1' '2' '3'}}}, {{randomInt lower=5 upper=9}} - wiremock-standalone

I am trying to use Pick random helper method for my standalone wiremocks.
I am able to use helper {{randomValue length=10 type='NUMERIC'}}
However when I try to use other helpers like {{{pickRandom '1' '2' '3'}}} or {{randomInt lower=5 upper=9}}
It starts throwing exceptions
I am trying to pick random value for a Attribute in my response body to have random value either from a range of values or from a list of values like below
"response": {
"status": 200,
"fixedDelayMilliseconds": 1000,
"body": "{"accountId": "{{{pickRandom '1' '2' '3'}}}"}",
"transformers":[
"response-template"
]
but its give cannot find helper exception while randomValue works fine.
Any inputs are most welcomes. I am using wiremock-standalone-2.26.3

Issue was with standalone wiremock version 2.26.3 which was not compatible for these two methods.
After upgrading to latest version 2.32.0 working fine now.

Related

Is there a way to get the number of registered nodes by Selenium Grid other than with http://localhost:4444/grid/console

In order to run multiple tests in parallel, I would like to know how many nodes are already running at some point.
I have looked into many posts on this subject, but all of them include using http://localhost:4444/grid/console : I don't want to check this page.
I was thinking about sending a message to the hub each time a node is created. so the hub increments its count. But I can't find a way to do that.
Does anyone have a different solution ? Maybe using seleniumgrid parameters or command, I'm surprised this number is not stored somewhere?
The selenium grid has an API. You can do this:
http://hub_ip_address:4444/grid/api/hub
and parse the json it returns for "slotCounts"
{
"success":true,
"capabilityMatcher":"org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
"newSessionWaitTimeout":-1,
"throwOnCapabilityNotPresent":true,
"registry":"org.openqa.grid.internal.DefaultGridRegistry",
"cleanUpCycle":5000,
"custom":{
},
"host":"XX.XXX.XX.XXX",
"maxSession":10,
"servlets":[
"ConsoleServlet"
],
"withoutServlets":[
],
"browserTimeout":0,
"debug":false,
"port":4444,
"role":"hub",
"timeout":300000,
"enablePassThrough":true,
"newSessionRequestCount":0,
"slotCounts":{
"free":9,
"total":12
}
}

Pass large parameters to browser

I created more than 20 reports using crystal report. Now I am integrating them to my API service. One particular report uses the following parameters:
lngCompanyId=1
szITSfromCompany=Sample
strGroupBy=Region
strGroupBy1=Greater Accra
strQuery1='and #tblRetOutletSumm.iRegionID=4'
strQuery2='and #tblRetOutletSumm.iDistrictID=8'
strQuery3='2016-10-27'
strQuery4='2016-10-27'
strPicHeight=1
strPicWeight=1
Now i have to pass them to my web browser to generate the report. I tried the following URL after running the project:
http://localhost:20010/Home/CreateSummaryReport?lngCompanyId=1&szITSfromPersol=Sample&strGroupBy=Region&strGroupBy1=Greater Accra&strQuery1=and #tblRetOutletSumm.iRegionID=4&strQuery2=and #tblRetOutletSumm.iDistrictID=8&strQuery3=2016-10-27&strQuery4=2016-10-27&strPicHeight=1&strPicWeight=1
It broke the code. It passed up to strGroupBy1 which is Greater Accra but when it came to strQuery1, it only showed me the first word which is and instead of and #tblRetOutletSumm.iRegionID=4 and all the remaining parameters threw null values.
I know the '#' tag causes the problem, so how do I pass the parameter? Or should I change a the database procedure?
Changing the '# tag' by ascii symbol solved the issue.
I changed the '#' tag by '%23' and the issue is solved.
Somad

Spring Data Rest 2.4 doesn't work with {?page,size,sort} links

I've faced with the following problem:
Spring Data Rest version: org.springframework.data:spring-data-rest-webmvc:2.4.0.RELEASE
When i perform the query: http://localhost:8080/data/entities/ - the base query for my Rest servlet.
It produces the links for all entities i have. The links has the following standard form:
"entityA": {
"href": "http://localhost:8080/data/entities/entitiA{?page,size,sort}",
"templated": true
}
When i try to perform the generated link:
http://localhost:8080/data/entities/entitiA{?page,size,sort}
I have 404 NotFound exception.
But when i execute
http://localhost:8080/data/entities/entitiA
it works fine.
Do you have any ideas about it or could you suggest any solution to execute links in the format:
http://localhost:8080/data/entities/entitiA{?page,size,sort}
Thanks!
Sometimes it is worth to look at the documentation ;-)
http://docs.spring.io/spring-data/rest/docs/2.4.0.RELEASE/reference/html/#paging-and-sorting
{?page,size,sort} is a template. It tells you which request parameters the resource supports. You are not supposed to use a templated link as it is in the response - you expand it first.
So a request like this should be working
http://localhost:8080/cars/data/entities/entitiA?page=1&size=20

Ruby mongodb: Three newly created objects doesn't appear to exist during testing

I'm using mongodb to store some data. Then I have a function that gets the object with the latest timestamp and one with the oldest. I haven't experienced any issues during development or production with this method but when I try to implement a test for it the test fails approx 20% of the times. I'm using rspec to test this method and I'm not using mongoid or mongomapper. I create three objects with different timestamps but get a nil response since my dataset contains 0 objects. I have read a lot of articles about write_concern and that it might be the problem with "unsafe writes" but I have tried almost all the different combinations with these parameters (w, fsync, j, wtimeout) without any success. Does anyone have any idea how to solve this issue? Perhaps I have focused too much with the write_concern track and that the problems lies somewhere else.
This is the method that fetches the latest and oldest timestamp.
def first_and_last_timestamp(customer_id, system_id)
last = collection(customer_id).
find({sid:system_id}).
sort(["t",Mongo::DESCENDING]).
limit(1).next()
first = collection(customer_id).
find({sid:system_id}).
sort(["t",Mongo::ASCENDING]).
limit(1).next()
{ min: first["t"], max: last["t"] }
end
Im inserting data using this method where data is a json object.
def insert(customer_id, data)
collection(customer_id).insert(data)
end
I have reverted back to use the default for setting up my connection
Mongo::MongoClient.new(mongo_host, mongo_port)
I'm using the gem mongo (1.10.2). I'm not using any fancy setup for my mongo database. I've just installed mongo using brew on my mac and started it. The version of my mongo database is v2.6.1.

Backbone using GET instead of PUT or POST

I'm having some issues with a Backbone project that I am working on.
I have the following model:
class App.Models.Purchaseorder extends Backbone.Model
url: ->
base = 'api/purchaseorders'
if this.isNew()
base
else
base + '/' + this.id;
urlRoot: 'api/purchaseorders'
When I run the following in the console:
po = new App.Models.Purchaseorders;
po.set({'po_number': '1234', 'locale': 'Home', 'po_date': '3/22/2012'});
it appears to set the attributes correctly. However, if I run
po.save()
I would expect it to do a POST request to the api/purchaseorders URL. When I debug through the save() and sync() functions in the Backbone JS, it looks like it is indeed running a POST, but at the last minute, it looks as if it is really doing a GET http://i.imgur.com/dQK88.png
I am a little confused as to why this would be happening. I am having similar issues when trying to do an update -- which should be doing a PUT. I am assuming something is funky in the model, but I have no clue what it could be.
Any help would be greatly appreciated.
Thanks!
I tested the code you have in the question (had to call new App.Models.Purchaseorder, without the s, though FYI) and it does a POST as expected.
What version of Backbone and Underscore are you using?
Here's a fiddle.