How to ignore nodes with It values when comparing two xmls with XMLUnit2 - xmlunit-2

Comparing two xml files in soapui using groovy with XMLUnit2, Have some weird cases which are different in both files, but are acceptable. So have to ignore/skip those.
ResXML1:
<alpha:Errors>
<alpha:Error ShortText="SHiff" Type="11">Generic error occured.</alpha:Error>
<alpha:Error ShortText="SHiff" Type="12">Generic error occured.</alpha:Error>
</alpha:Errors>
<ShiftAttributes>
<ShiftAttribute ShiftAttributeCode="41"/>
<ShiftAttribute ShiftAttributeCode="17"/>
</ShiftAttributes>
<alpha:PriceInfo AgeQualifyingCode="10" Amount="19999.00" DiscountTypes="3" AMZAmount="225.00" NetAmount="19999.00" MCH="1" ValueAddAmount="150.00"/>
ResXML2:
<alpha:Warnings>
<alpha:Warning ShortText="SHiff" Type="11">Generic error occurred.</alpha:Warning>
</alpha:Warnings>
<ShiftAttributes>
<ShiftAttribute ShiftAttributeCode="17"/>
<ShiftAttribute ShiftAttributeCode="41"/>
</ShiftAttributes>
<alpha:PriceInfo AgeQualifyingCode="10" Amount="19999.0" DiscountTypes="3" AMZAmount="225.0" NetAmount="19999.0" MCH="1" ValueAddAmount="150.0"/>
If anyone have any idea, please help me in below conditions.
1) How to ignore child attribute order? tried different nodematchers(byXpath, byNameandText etc..), but no luck.
<ShiftAttribute ShiftAttributeCode="41"/>
<ShiftAttribute ShiftAttributeCode="17"/>
2) How to ignore decimal value, 100.0 & 100.00. Tried to use BigDecimalElementDifferenceEvaluator, but cannot able to complete in soapui. If we have any easy method please help me?

Found solution for first part of the above question
diff = DiffBuilder.compare(ResXML1).withTest(ResXML2)
.withNodeMatcher(
new DefaultNodeMatcher(
ElementSelectors.conditionalBuilder()
.whenElementIsNamed("ShiftAttribute")
.thenUse( ElementSelectors.byNameAndAttributes("ShiftAttributeCode"))
.elseUse(ElementSelectors.byName)
.build()
)
).build();

Related

Joining Two Tables with Different Data types MS ACCESS - 'type mismatch in expression' error

I'm trying to run a query on access using two live CSVs which has a common field with different data types(numbers and short text). I've discovered that you can join different data types using 'CStr'. I've added the 'CStr' to my code on the sql view. Please find the see the code below.
This gives me the output i want on access and i can now see the output when i click on 'datasheet view'. However, when i try to export the data (i'm actually trying create a export specification so that i can export a csv using macro) as a csv i'm getting a 'type mismatch in expression' error message.
Here's my code:
SELECT Sixthform_Reg_Year_Groups.Forename,
Sixthform_Reg_Year_Groups.Surname,
Sixthform_Reg_Year_Groups.Reg, Students.objectGUID
FROM Sixthform_Reg_Year_Groups INNER JOIN
Students
ON CStr(Sixthform_Reg_Year_Groups.Person_id) = Students.employeeID
WHERE (((Sixthform_Reg_Year_Groups.Reg)="12E"));`
I've also tried adding 'CStr' on both sides. as below, but experiencing the same issue.
FROM Sixthform_Reg_Year_Groups INNER JOIN
Students
ON CStr(Sixthform_Reg_Year_Groups.Person_id) = CStr (Students.employeeID)
WHERE (((Sixthform_Reg_Year_Groups.Reg) = "12E"));`
And of course, without 'CStr' i can't even view the output on 'datasheet view'. Every time when i click on datasheet view it's giving me the 'type mismatch in expression' error message.
Any help in resolving this would be much appreciated.
Thanks in advance.
Additinal info: the data types are EmpoyeeID is 'Short Text' and Person ID is 'Number'
Try the other way round:
ON Sixthform_Reg_Year_Groups.Person_id = Val(Students.employeeID)
and/or prevent Null errors:
ON CStr(Nz(Sixthform_Reg_Year_Groups.Person_id, 0)) = Nz(Students.employeeID)
OK guys, I've managed to resolve this issue, It turned out to be simple in the end. This is what i did.
Basically, I re imported the linked table. This time on the import window i clicked on 'advanced' and changed the data type to 'short text' on the 'person ID' column to match with the 'employeeID' data type. And then all problems solved. (I didn't know you could do this)
Thank you all for your replies. Going through your comments guided me to the right path.
Much appreciated.

R - Error in rsqlite_bind_rows(rs#ptr, value) :

I hope you can help me with this.
I've imported 3 json files in R and used streamed in to get 3 df's on which I can do queries with sqldf. On 2 of them it works fine, but on the third one I get this error when using:
sqldf('select * from fixfull where checksum is "121"')
Error in rsqlite_bind_rows(rs#ptr, value) :
Can only bind lists of raw vectors (or NULL)
I get the same error message for all other queries on this df. Don't know what is wrong specifically, and can't find other related errors on stackoverflow.
Could someone help?
Thanks a lot!!
Vmontreal

Product Index Using Django ORM

I have a list of Products with a field called 'Title' and I have been trying to get a list of initial letters with not much luck. The closes I have is the following that dosn't work as 'Distinct' fails to work.
atoz = Product.objects.all().only('title').extra(select={'letter': "UPPER(SUBSTR(title,1,1))"}).distinct('letter')
I must be going wrong somewhere,
I hope someone can help.
You can get it in python after the queryset got in, which is trivial:
products = Project.objects.values_list('title', flat=True).distinct()
atoz = set([i[0] for i in products])
If you are using mysql, I found another answer useful, albeit using sql(django execute sql directly):
SELECT DISTINCT LEFT(title, 1) FROM product;
The best answer I could come up with, which isn't 100% ideal as it requires post processing is this.
atoz = sorted(set(Product.objects.all().extra(select={'letter': "UPPER(SUBSTR(title,1,1))"}).values_list('letter', flat=True)))

How to locate the node in JCR using uuid from query

This is the error I get.
16.03.2016 12:02:16.413 WARN [xxx.xxx.xx.xxx [1458147736268] GET /en/employees-leaders/employee-s-toolkit2/epd-update/epd-update-archives/caterpillar-news/upcoming-brand-webinarfocusonmarketing.html HTTP/1.1] com.day.cq.wcm.core.impl.LanguageManagerImpl Error while
retrieving language property. javax.jcr.AccessDeniedException: cannot
read item xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (alpha-numeric)
I am trying to locate the node in JCR using the xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, which I believe is uuid, using a query in AEM.
Is the xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx actually a uuid?
How do I locate the source i.e node, causing the issue?
I tried running a sql with the above id in the jcr, but it returned no result.
//*[jcr:contains(., '91186155-45ad-474-9ad9-d5156a398629')] order by #jcr:score descending
Any other insights would be much appreciated.
You don't need a query if you know the Node's UUID, just use the Session.getNodeByIdentifier(String id) method.
Your query is not SQL as you stated, it's XPATH. Is that a typo or did you run the query incorrectly?
It certainly looks like a UUID. You can query for the jcr:uuid property or you can continue doing a full text search.
XPATH:
/jcr:root//*[jcr:contains(., '91186155-45ad-474-9ad9-d5156a398629')]
/jcr:root//*[#jcr:uuid='91186155-45ad-474-9ad9-d5156a398629']
JCR-SQL2:
SELECT * FROM [nt:base] AS s WHERE contains(s.*, '91186155-45ad-474-9ad9-d5156a398629')
SELECT * FROM [nt:base] WHERE [jcr:uuid] = '91186155-45ad-474-9ad9-d5156a398629'
What read permissions does your account have? You're going to find a lot of results for a jcr:uuid query will be under /jcr:system/jcr:versionStorage.
Use QueryBuilderDebugger, (localhost:4502/libs/cq/search/content/querydebug.html) and run similar query as below to get the node for a given uuid:
property=jcr:uuid
property.value=e69b256e-a466-3730-866b-de22c82ab8ck
path=/home
type=rep:Group
p.limit=10

Mule ESB: How to do Condition checking in Datamapper using Xpath

i'm facing issue in xpath-I need do a check two attribute values, if the condition satisfies need to do hard code my own value. Below is my xml.
I need to check the condition like inside subroot- if ItemType=Table1 and ItemCondition=Chair1 then i have to give a hard coded value 'Proceed'( this hard coded value i will map to target side of datamapper).
<Root>
<SubRoot>
<ItemType>Table1</ItemType>
<ItemCondition>Chair1</ItemCondition>
<ItemValue>
.......
</ItemValue>
</SubRoot>
<SubRoot>
<ItemType>Table2</ItemType>
<ItemCondition>chair2</ItemCondition>
<ItemValue>
.......
</ItemValue>
</SubRoot>
....Will have multiple subroot
</Root>
I have tried to define rules as below, but it is throwing error
Type: String
Context:/Root
Xpath: substring("Proceed", 1 div boolean(/SubRoot[ItemType="Table1" and ItemCondition="Chair1"]))
But it is throwing error like
net.sf.saxon.trans.XPathException: Arithmetic operator is not defined for arguments of types (xs:integer, xs:boolean)
Is there any other shortcut way to perform this.Could you please help me, i have given lot more effort. Not able to resolve it. Thanks in advance.
I am not sure where you are applying this but the XPath expression you are looking for is:
fn:contains(/Root/SubRoot[2]/ItemCondition, "chair") and fn:contains(/Root/SubRoot[2]/ItemType, "Table")
So here is an example returning "Proceed" or "Stop" as appropriate:
if (fn:contains(/Root/SubRoot[1]/ItemCondition, "Chair") and fn:contains(/Root/SubRoot[2]/ItemType, "Table")) then 'Proceed' else 'Stop'
To implement the above condition , i was initially tired to do in xpath, gave me lot of error. I have implemented by simple if else condition in script part of data mapper
if ( (input.ItemType == 'Table') and (input.ItemCondition == 'chair')) {
output.Item = 'Proceed'}
else {
output.Item = 'Stop '};
Make sure about your precedence. Example, Here in the xml structure( or converted POJO) ItemType has to be checked first then followed with ItemCondition.
&& not seems to be working for me, change to 'and' operator
If you were first time trying to implement the logic. It may help you.