pyral.restapi.RallyRESTAPIError: 422 Cannot parse object reference from "/iteration/AXP 22.4.19" - pyral

While creating a test set using pyral it cannot parse object reference.
createTestSet=rally.put('TestSet',{'Name':'Dummy Test Setttttt','Iteration':'/iteration/AXP 22.4.19'})
createTestSet=rally.put('TestSet',{'Name':'Dummy Test Setttttt','Iteration':'iteration/AXP 22.4.19'})

Related

How to match some values of object using sinon stub

I've been writing test using sinon. During the same I wrote stub where some input parameters are passed and an object is returned. This object returns some values and a random date value generated by system at the time of execution. So need guidance on following.
How can I handle the same as the matching arguments are static in nature and I don't know the possible value of the date generated by actual code.
How can we skip certain key values of an object using sinon. i.e. say object has following values. const object = {name: "abc", employeeNumber : "123"} I only want to check if name is "abc" and don't need to match employeeNumber.
From the sinon.match docs:
Requires the value to be not null or undefined and have at least the same properties as expectation.
From the sinon.assert.match docs:
Uses sinon.match to test if the arguments can be considered a match.
Example:
test('partial object match', () => {
const object = { name: "abc", employeeNumber : "123" };
sinon.assert.match(object, { name: 'abc' }); // SUCCESS
})

soapui context properties in script assertion

I've two test case A and B under one test suite
I am setting the context property in script assertion of one of the test step of B
def holder = new XmlHolder( messageExchange.responseContentAsXml )
context.setProperty("xmlHolder", holder)
I am getting the context property in script assertion of one of the test step of A
def Holder=context.getProperty("xmlHolder")
log.info(Holder)
but the value of "Holder" is printed null
I just want to set it in one TC and get it in the other one.
EDIT
Found this , and I was trying to set property like this. I already had a Runner created in script assertion.
Runner.getTestCase().setPropertyValue("xmlHolder", holder)
But receiving a null error
I could do
Runner.getTestCase().setPropertyValue("xmlHolder", "A")
Just wondering , if TC properties can hold an Object compare to string. So, my original question remains as it is.
Based on above comments, got this working
setting property in script assertion of B
context.testCase.testSuite.setPropertyValue('xmlHolder', messageExchange.responseContentAsXml)
getting property in script assertion of B and converting it to XmlHolder object
def HolderContent=context.testCase.testSuite.getPropertyValue('xmlHolder')
def Holder = new XmlHolder ( HolderContent)

Mule - Pass Parameters to datamapper and access them in xpath conditions

How to pass parameters to datamapper in mule and access them. (In XSLT, I pass them as context parameters, receive them in param and access using $ symbol). I need to do the same thing in datamapper. Any suggestions/links/example are appreciated.
Approach1:
We are using invokeTransformer method in datamapper
output.abc= invokeTransformer("MyTransformer",input.abcdef);
This MyTransformer is a java component which has this default method overridden.
#Override
public String transformMessage(MuleMessage message, String outputEncoding)
throws TransformerException {
System.out.println("Inside transformer" +message.getProperty ("sessionVariable1",PropertyScope.SESSION));
return message.getProperty("sessionVariable1",PropertyScope.SESSION);
But, the problem is I am not calling this transformer from mule flow. But, invoking it from datamapper. Hence the argument 'message' does not get passed. So, Unable to retrive that session variable to return to datamapper. Is there a way to send this argument(MuleMessage from datamapper)?
You can use input arguments with DataMapper and then refer to them in the output:
<set-variable variableName="testvar" value="value of testvar"/>
<data-mapper:transform config-ref="new_mapping_grf"">
<data-mapper:input-arguments>
<data-mapper:input-argument key="testvar">#[flowVars['testvar']]</data-mapper:input-argument>
</data-mapper:input-arguments>
</data-mapper:transform>
and
output.myField = invokeTransformer("MyTransformer",inputArguments.testvar);
or
output.myField = inputArguments.testvar;
Adding input arguments available in the DataMapper GUI through the input side green plus icon.

passing object to the struts action in unit testing

I want to pass java.util.Date object to the struts action from unit test.
Format frmt = new SimpleDateFormat("yyyy/dd/MM");
Date objStartDate = Calendar.getInstance().getTime();
request.setParameter("startDate", frmt.format(objStartDate));
i also create new setter method in java class,
public void setStartDate(String startDate) throws ParseException {
DateFormat df = new SimpleDateFormat("yyyy/dd/MM");
this.startDate = df.parse(startDate);
}
I tried this but it doesn't work.
So How should i pass the object through unit test?
You have to use Request reference like below.
action.servletRequest = new HttpServletRequestSimulator(null);
where action is reference of your Action class.
I think this will solve your problem.

How to get OID of a BSON object as a hex string?

I am using the mongo-cxx driver trying to convert the object ID of a BSON object to a string
BSONObj r=some_function();
BSONElement oi;
r.getObjectID(oi);
OID o=oi.__oid();
cout<<"oid:"<<o.toString()<<endl;`
I am sure that the BSONObj has valid data but I get the following error:
BSONElement: bad type #somenumber
The query object returns a pointer to the buffer where the BSONObj is stored.
I went wrong when I did not use the function BSONObj::getOwned() to request a copy of the BSONObj which was causing the exception.