@Test
  public void testParametricMethod() throws Exception {
    final ProjectDataModelOracle projectLoader =
        ProjectDataModelOracleBuilder.newProjectOracleBuilder()
            .addClass(Purchase.class, new HashMap<String, FactBuilder>())
            .build();

    final PackageDataModelOracle packageLoader =
        PackageDataModelOracleBuilder.newPackageOracleBuilder(
                "org.kie.workbench.common.widgets.client.datamodel.testclasses")
            .setProjectOracle(projectLoader)
            .build();

    // Emulate server-to-client conversions
    final MockAsyncPackageDataModelOracleImpl oracle = new MockAsyncPackageDataModelOracleImpl();
    final Caller<IncrementalDataModelService> service =
        new MockIncrementalDataModelServiceCaller(packageLoader);
    oracle.setService(service);

    final PackageDataModelOracleBaselinePayload dataModel =
        new PackageDataModelOracleBaselinePayload();
    dataModel.setPackageName(packageLoader.getPackageName());
    dataModel.setModelFields(packageLoader.getProjectModelFields());
    dataModel.setFieldParametersType(packageLoader.getProjectFieldParametersType());
    PackageDataModelOracleTestUtils.populateDataModelOracle(
        mock(Path.class), new MockHasImports(), oracle, dataModel);

    assertNotNull(oracle);

    assertEquals(
        "Product", oracle.getParametricFieldType("Purchase", "customerPurchased(Integer)"));
  }
  @Test
  public void testPackageDMOParametricReturnTypes() throws Exception {
    final Map<String, FactBuilder> discoveredFieldFactBuilders = new HashMap<String, FactBuilder>();
    final ProjectDataModelOracle projectLoader =
        ProjectDataModelOracleBuilder.newProjectOracleBuilder()
            .addClass(Purchase.class, discoveredFieldFactBuilders)
            .addClass(Product.class, discoveredFieldFactBuilders)
            .build();

    final PackageDataModelOracle packageLoader =
        PackageDataModelOracleBuilder.newPackageOracleBuilder(
                "org.kie.workbench.common.widgets.client.datamodel.testclasses")
            .setProjectOracle(projectLoader)
            .build();

    // Emulate server-to-client conversions
    final MockAsyncPackageDataModelOracleImpl oracle = new MockAsyncPackageDataModelOracleImpl();
    final Caller<IncrementalDataModelService> service =
        new MockIncrementalDataModelServiceCaller(packageLoader);
    oracle.setService(service);

    final PackageDataModelOracleBaselinePayload dataModel =
        new PackageDataModelOracleBaselinePayload();
    dataModel.setPackageName(packageLoader.getPackageName());
    dataModel.setModelFields(packageLoader.getProjectModelFields());
    dataModel.setFieldParametersType(packageLoader.getProjectFieldParametersType());
    PackageDataModelOracleTestUtils.populateDataModelOracle(
        mock(Path.class), new MockHasImports(), oracle, dataModel);

    assertNotNull(oracle);

    assertEquals(3, oracle.getFactTypes().length);

    List<String> list = Arrays.asList(oracle.getFactTypes());

    assertTrue(list.contains("Purchase"));
    assertTrue(list.contains("Product"));

    assertEquals("java.util.Collection", oracle.getFieldClassName("Purchase", "items"));
    assertEquals(DataType.TYPE_COLLECTION, oracle.getFieldType("Purchase", "items"));
    assertEquals("Product", oracle.getParametricFieldType("Purchase", "items"));
  }
 public static void populateDataModel(
     final PackageDataModelOracle oracle,
     final PackageDataModelOracleBaselinePayload dataModel,
     final Set<String> usedFullyQualifiedClassNames) {
   dataModel.setProjectName(oracle.getProjectName());
   dataModel.setPackageName(oracle.getPackageName());
   dataModel.setModelFields(
       setupModelFields(
           usedFullyQualifiedClassNames,
           oracle.getProjectModelFields(),
           oracle.getPackageGlobals()));
   dataModel.setFieldParametersType(
       filterFieldParametersTypes(
           usedFullyQualifiedClassNames, oracle.getProjectFieldParametersType()));
   dataModel.setEventTypes(
       filterEventTypes(usedFullyQualifiedClassNames, oracle.getProjectEventTypes()));
   dataModel.setTypeSources(
       filterTypeSources(usedFullyQualifiedClassNames, oracle.getProjectTypeSources()));
   dataModel.setSuperTypes(
       filterSuperTypes(usedFullyQualifiedClassNames, oracle.getProjectSuperTypes()));
   dataModel.setTypeAnnotations(
       filterTypeAnnotations(usedFullyQualifiedClassNames, oracle.getProjectTypeAnnotations()));
   dataModel.setTypeFieldsAnnotations(
       filterTypeFieldsAnnotations(
           usedFullyQualifiedClassNames, oracle.getProjectTypeFieldsAnnotations()));
   dataModel.setJavaEnumDefinitions(oracle.getProjectJavaEnumDefinitions());
   dataModel.setWorkbenchEnumDefinitions(oracle.getPackageWorkbenchDefinitions());
   dataModel.setMethodInformation(
       filterMethodInformation(
           usedFullyQualifiedClassNames, oracle.getProjectMethodInformation()));
   dataModel.setCollectionTypes(
       filterCollectionTypes(usedFullyQualifiedClassNames, oracle.getProjectCollectionTypes()));
   dataModel.setDslConditionSentences(oracle.getPackageDslConditionSentences());
   dataModel.setDslActionSentences(oracle.getPackageDslActionSentences());
   dataModel.setGlobalTypes(oracle.getPackageGlobals());
   dataModel.setPackageNames(oracle.getProjectPackageNames());
 }