@Test
public void parseComplexClassTest() throws NoSuchMethodException, SecurityException {

    ServiceModel model = serviceClassParser.parseServiceClass(TestComplexServiceClass.class, settings);
    assertEquals(1, model.innerServiceModels().size());
    Type genericReturnType = TestComplexServiceClass.class.getMethod("allOptionsPost", String.class, Integer.class, DataObject.class).getGenericReturnType();
    assertEquals(ImmutableSet.of(Boolean.class, ImmutablesObject.class, MyObject.class, GenericObject.class, Integer.class, String.class, DataObject.class, genericReturnType), model.referencedTypes());
    assertEquals("TestComplexServiceClass", model.name());
    assertEquals("testComplexService", model.innerServiceModels().get(0).servicePath());
    List<ServiceEndpointModel> endpoints = Lists.newArrayList();
    {
        ServiceEndpointParameterModel aParam = ImmutableServiceEndpointParameterModel.builder().pathParam("a").javaType(String.class).tsType(TsType.String).build();
        ServiceEndpointParameterModel bParam = ImmutableServiceEndpointParameterModel.builder().queryParam("b").javaType(Integer.class).tsType(TsType.Number).build();
        ServiceEndpointParameterModel dataParam = ImmutableServiceEndpointParameterModel.builder().javaType(DataObject.class).tsType(new TsType.ReferenceType(new Symbol("DataObject"))).build();
        endpoints.add(ImmutableServiceEndpointModel.builder().javaReturnType(genericReturnType)
                                                             .tsReturnType(new TsType.ReferenceType(new Symbol("GenericObject<MyObject>")))
                                                             .parameters(Lists.newArrayList(aParam, dataParam, bParam))
                                                             .endpointName("allOptionsPost")
                                                             .endpointPath("allOptionsPost/{a}")
                                                             .endpointMethodType("POST")
                                                             .endpointRequestMediaType(MediaType.APPLICATION_JSON)
                                                             .build());
    }
    {
        ServiceEndpointParameterModel xParam = ImmutableServiceEndpointParameterModel.builder().queryParam("x").javaType(Boolean.class).tsType(TsType.Boolean).build();
        endpoints.add(ImmutableServiceEndpointModel.builder().javaReturnType(MyObject.class)
                                                             .tsReturnType(new TsType.ReferenceType(new Symbol("MyObject")))
                                                             .parameters(Lists.newArrayList(xParam))
                                                             .endpointName("queryGetter")
                                                             .endpointPath("queryGetter")
                                                             .endpointMethodType("GET")
                                                             .build());
    }
    {
        ServiceEndpointParameterModel dataParam = ImmutableServiceEndpointParameterModel.builder().javaType(DataObject.class).tsType(new TsType.ReferenceType(new Symbol("DataObject"))).build();
        endpoints.add(ImmutableServiceEndpointModel.builder().javaReturnType(ImmutablesObject.class)
                                                             .tsReturnType(new TsType.ReferenceType(new Symbol("ImmutablesObject")))
                                                             .parameters(Lists.newArrayList(dataParam))
                                                             .endpointName("simplePut")
                                                             .endpointPath("simplePut")
                                                             .endpointMethodType("PUT")
                                                             .build());
    }
    // To string because TsType has no equals method
    assertEquals(endpoints.toString(), model.innerServiceModels().get(0).endpointModels().toString());
}