* Test method for {@link org.corrib.s3b.mbb.beans.ServiceChain#decode(java.lang.String)}.
*/
@Test
public final void testDecode() {
for(CallChainTest cct : this.tests) {
ServiceChain chain = ServiceChain.decode(cct.getCall(), cct.getBaseUrl());
System.out.println(chain);
if(cct.getCalls().size() != chain.getServices().size())
failNotEquals("Service test failed ["+cct.getId()+"]\n - number of resulted services in a chain does not equal\n", cct.getCalls().size(), chain.getServices().size());
for(int i = 0; i < cct.getCalls().size(); i++) {
CallTest ct = cct.getCalls().get(i);
MBBService service = chain.getServices().get(i);
if(!ct.getMatchedService().getImplementation().equals(service.getClass()))
failNotEquals("Results implmentation test failed ["+cct.getId()+"]", ct.getMatchedService().getImplementation(), service.getClass());
if(ct.getResults().size() != service.getParams().size()) {
failNotEquals("Results size test failed ["+cct.getId()+" : "+i+"]", ct.getResults().size(), service.getParams().size());
}
for(int j = 0; j < ct.getResults().size(); j++)
if(ct.getResults().get(j) != null && !ct.getResults().get(j).equals(service.getParams().get(j)))
failNotEquals("Expected results test failed ["+cct.getId()+"]", ct.getResults().get(j), service.getParams().get(j));
}
if(cct.getMetaService() != null || chain.getMetaservice() != null) {
if(cct.getMetaService() == null || chain.getMetaservice() == null)
failNotEquals("Results meta test failed ["+cct.getId()+"]", cct.getMetaService(), chain.getMetaservice());
if(!cct.getMetaService().getMatchedService().getImplementation().equals(chain.getMetaservice().getClass()))
failNotEquals("Results meta class test failed ["+cct.getId()+"]", cct.getMetaService().getMatchedService().getImplementation(), chain.getMetaservice().getClass());
if(cct.getMetaService().getResults()!=null || chain.getMetaservice().getParams()!=null) {
if(cct.getMetaService().getResults()==null || chain.getMetaservice().getParams()==null)
failNotEquals("Results meta param test failed ["+cct.getId()+"]", cct.getMetaService().getResults(), chain.getMetaservice().getParams());
if(cct.getMetaService().getResults().size() != chain.getMetaservice().getParams().size()) {
failNotEquals("Results meta param size test failed ["+cct.getId()+" : meta]", cct.getMetaService().getResults().size(), chain.getMetaservice().getParams().size());
}
for(int j = 0; j < cct.getMetaService().getResults().size(); j++)
if(cct.getMetaService().getResults().get(j) != null && !cct.getMetaService().getResults().get(j).equals(chain.getMetaservice().getParams().get(j)))
failNotEquals("Expected meta results test failed ["+cct.getId()+"]", cct.getMetaService().getResults().get(j), chain.getMetaservice().getParams().get(j));
}
}
}
}