public Map<String, SomeComplexObject> buildComplexMap(List<SomeComplexObject> listOfObjects) { Map<String, SomeComplexObject> returnMap = new HashMap<String, SomeComplexObject>(); for (SomeComplexObject obj : listOfObjects) { returnMap.put(obj.getStringParameter(), obj); } return returnMap; }
public boolean compareComplexDelegateMaps( Map<String, SomeComplexObject> map1, Map<String, SomeComplexObject> map2) { SomeComplexObject map1Complex1 = map1.get("object1"); SomeComplexObject map1Complex2 = map1.get("object2"); SomeComplexObject map1Complex3 = map1.get("object3"); SomeComplexObject map2Complex1 = map1.get("object1"); SomeComplexObject map2Complex2 = map1.get("object2"); SomeComplexObject map2Complex3 = map1.get("object3"); if (!map1Complex1.equals(map2Complex1)) { return false; } if (!map1Complex2.equals(map2Complex2)) { return false; } if (!map1Complex3.equals(map2Complex3)) { return false; } return true; }
public boolean compareComplexMaps( Map<String, SomeComplexObject> map1, Map<String, SomeComplexObject> map2) { SomeComplexObject map1Complex1 = map1.get("String value for aaa"); SomeComplexObject map1Complex2 = map1.get("String value for bbb"); SomeComplexObject map1Complex3 = map1.get("String value for ccc"); SomeComplexObject map2Complex1 = map1.get("String value for aaa"); SomeComplexObject map2Complex2 = map1.get("String value for bbb"); SomeComplexObject map2Complex3 = map1.get("String value for ccc"); if (!map1Complex1.equals(map2Complex1)) { return false; } if (!map1Complex2.equals(map2Complex2)) { return false; } if (!map1Complex3.equals(map2Complex3)) { return false; } return true; }
@Test(dataProvider = "TransportType") public void doTest(CougarClientWrapper.TransportType tt) throws Exception { // Create a some complex object SomeComplexObject someComplexObject1 = new SomeComplexObject(); someComplexObject1.setStringParameter("String value for aaa"); SomeComplexObject someComplex1 = someComplexObject1; CougarClientResponseTypeUtils cougarClientResponseTypeUtils2 = new CougarClientResponseTypeUtils(); Date dateParam1 = cougarClientResponseTypeUtils2.createDateFromString("2009-06-01T13:50:00.0Z"); someComplex1.setDateTimeParameter(dateParam1); someComplex1.setEnumParameter( com.betfair.baseline.v2.enumerations.SomeComplexObjectEnumParameterEnum.BAR); CougarClientResponseTypeUtils cougarClientResponseTypeUtils3 = new CougarClientResponseTypeUtils(); List<String> list1 = cougarClientResponseTypeUtils3.buildList( "aaa List Entry 1,aaa List Entry 2,aaa List Entry 3"); someComplex1.setListParameter(list1); // Create another some complex object SomeComplexObject someComplexObject4 = new SomeComplexObject(); someComplexObject4.setStringParameter("String value for bbb"); SomeComplexObject someComplex2 = someComplexObject4; CougarClientResponseTypeUtils cougarClientResponseTypeUtils5 = new CougarClientResponseTypeUtils(); Date dateParam2 = cougarClientResponseTypeUtils5.createDateFromString("2009-06-02T13:50:00.435Z"); someComplex2.setDateTimeParameter(dateParam2); someComplex2.setEnumParameter( com.betfair.baseline.v2.enumerations.SomeComplexObjectEnumParameterEnum.FOOBAR); CougarClientResponseTypeUtils cougarClientResponseTypeUtils6 = new CougarClientResponseTypeUtils(); List<String> list2 = cougarClientResponseTypeUtils6.buildList( "bbb List Entry 1,bbb List Entry 2,bbb List Entry 3"); someComplex2.setListParameter(list2); // Create another some complex object SomeComplexObject someComplexObject7 = new SomeComplexObject(); someComplexObject7.setStringParameter("String value for ccc"); SomeComplexObject someComplex3 = someComplexObject7; CougarClientResponseTypeUtils cougarClientResponseTypeUtils8 = new CougarClientResponseTypeUtils(); Date dateParam3 = cougarClientResponseTypeUtils8.createDateFromString("2009-06-03T13:50:00.435Z"); someComplex3.setDateTimeParameter(dateParam3); someComplex3.setEnumParameter( com.betfair.baseline.v2.enumerations.SomeComplexObjectEnumParameterEnum.FOO); CougarClientResponseTypeUtils cougarClientResponseTypeUtils9 = new CougarClientResponseTypeUtils(); List<String> list3 = cougarClientResponseTypeUtils9.buildList( "ccc List Entry 1,ccc List Entry 2,ccc List Entry 3"); someComplex3.setListParameter(list3); // Set up the client to use rescript transport CougarClientWrapper cougarClientWrapper10 = CougarClientWrapper.getInstance(tt); CougarClientWrapper wrapper = cougarClientWrapper10; BaselineSyncClient client = cougarClientWrapper10.getClient(); ExecutionContext context = cougarClientWrapper10.getCtx(); // Build complex map using objects created in import sheet CougarClientResponseTypeUtils cougarClientResponseTypeUtils11 = new CougarClientResponseTypeUtils(); Map<String, SomeComplexObject> complexMap = cougarClientResponseTypeUtils11.buildComplexMap( Arrays.asList(someComplex1, someComplex2, someComplex3)); // Create body parameter to be passed BodyParamComplexMapObject bodyParamComplexMapObject12 = new BodyParamComplexMapObject(); bodyParamComplexMapObject12.setComplexMap(complexMap); BodyParamComplexMapObject bodyParam = bodyParamComplexMapObject12; // Make call to the method via client and store response ComplexMapOperationResponseObject response14 = client.complexMapOperation(context, bodyParam); Map responseMap = response14.getResponseMap(); // Validate the received complex map matches the one passed in CougarClientResponseTypeUtils cougarClientResponseTypeUtils15 = new CougarClientResponseTypeUtils(); boolean mapsMatch = cougarClientResponseTypeUtils15.compareComplexMaps(complexMap, responseMap); assertEquals(true, mapsMatch); }