Codota Logo
FieldData
Code IndexAdd Codota to your IDE (free)

How to use
FieldData
in
org.drools.ide.common.client.modeldriven.testing

Best Java code snippets using org.drools.ide.common.client.modeldriven.testing.FieldData (Showing top 20 results out of 315)

  • Common ways to obtain FieldData
private void myMethod () {
FieldData f =
  • Codota Iconnew FieldData()
  • Smart code suggestions by Codota
}
origin: org.chtijbug.drools/droolsjbpm-ide-common

FieldData fieldData = new FieldData();
fieldData.setName(name);
fieldData.setValue(reader.getValue());
reader.moveUp();
  reader.moveDown();
  String value = reader.getValue();
  fieldData.setNature(Integer.parseInt(value));
  reader.moveUp();
if (fieldData.getValue() != null && fieldData.getValue().startsWith("=[")) {
  CollectionFieldData collectionFieldData = new CollectionFieldData();
  collectionFieldData.setName(name);
  String list = fieldData.getValue().substring(2, fieldData.getValue().length() - 1);
      FieldData subFieldData = new FieldData();
      subFieldData.setName(name);
      subFieldData.setValue(value);
      collectionFieldData.getCollectionFieldList().add(subFieldData);
    FieldData subFieldData = new FieldData();
    subFieldData.setName(name);
    subFieldData.setValue(list);
    collectionFieldData.getCollectionFieldList().add(subFieldData);
origin: org.drools/droolsjbpm-ide-common

if (fieldData.getValue().startsWith("=")) {
  return new ExpressionFieldPopulator(factObject,
      fieldData.getName(),
      fieldData.getValue().substring(1));
} else if (fieldData.getNature() == FieldData.TYPE_ENUM) {
  return new EnumFieldPopulator(factObject,
      fieldData.getName(),
      fieldData.getValue(),
      typeResolver,
      classLoader);
} else if (isDate(fieldData.getName())) {
  return new DateFieldPopulator(
      factObject,
      getFieldType(fieldData.getName()),
      fieldData.getName(),
      fieldData.getValue());
} else {
  return new SimpleFieldPopulator(factObject,
      fieldData.getName(),
      fieldData.getValue());
origin: org.drools/droolsjbpm-ide-common

public FieldData(String name,
         String value) {
  this.setName(name);
  this.setValue(value);
}
origin: org.drools/droolsjbpm-ide-common

  @Test
  public void testAdd() {
    FactData fd = new FactData("x", "y", new ArrayList(), false );
    assertEquals(0, fd.getFieldData().size());
    fd.getFieldData().add(new FieldData("x", "y"));
    assertEquals(1, fd.getFieldData().size());
    fd.getFieldData().add(new FieldData("q", "x"));
    assertEquals(2, fd.getFieldData().size());
  }
}
origin: org.drools/droolsjbpm-ide-common

@Test
public void testPopulateEnum() throws Exception {
  FieldData fieldData = new FieldData(
      "cheeseType",
      "CheeseType.CHEDDAR");
  fieldData.setNature(FieldData.TYPE_ENUM);
  FactData factData = new FactData("Cheese",
      "c1",
      asList((Field) fieldData),
      false);
  factPopulator.add(new NewFactPopulator(populatedData, getTypeResolver(), getClassLoader(), factData));
  factPopulator.populate();
  assertTrue(populatedData.containsKey("c1"));
  Cheese cheese = (Cheese) populatedData.get("c1");
  assertEquals(CheeseType.CHEDDAR, cheese.getCheeseType());
}
origin: org.drools/droolsjbpm-ide-common

@Test
public void testLoadLegacyTestScenario() throws Exception {
  StringBuffer contents = new StringBuffer();
  BufferedReader reader = null;
  try {
    reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("testLoadLegacyTestScenario.xml")));
    String text = null;
    while ((text = reader.readLine()) != null) {
      contents.append(text);
    }
  } catch (Exception e) {
    if (reader != null) {
      reader.close();
    }
    throw new IllegalStateException("Error while reading file.", e);
  }
  Scenario scenario = ScenarioXMLPersistence.getInstance().unmarshal(contents.toString());
  verifyFieldDataNamesAreNotNull(scenario);
  FactData factData = (FactData) scenario.getFixtures().get(0);
  assertTrue(factData.getFieldData().get(0) instanceof FieldData);
  FieldData fieldData = (FieldData) factData.getFieldData().get(0);
  assertEquals("42", fieldData.getValue());
  assertEquals("age", fieldData.getName());
}
origin: org.drools/droolsjbpm-ide-common

private String createExpression(CollectionFieldData field) {
  String result = "[";
  int index = 1;
  for (FieldData fieldData : field.getCollectionFieldList()) {
    result += fieldData.getValue().replace("=", "");
    if (index < field.getCollectionFieldList().size()) {
      result += ",";
    }
    index++;
  }
  return result + "]";
}
origin: org.drools/droolsjbpm-ide-common

private void verifyFieldDataNamesAreNotNull(Scenario sc) {
  for (Fixture fixture : sc.getFixtures()) {
    if (fixture instanceof FactData) {
      FactData factData = (FactData) fixture;
      for (Field field : factData.getFieldData()) {
        if (field instanceof FieldData) {
          FieldData fieldData = (FieldData) field;
          assertNotNull(fieldData.getName());
        }
      }
    }
  }
}
origin: org.drools/droolsjbpm-ide-common

@Test
public void testDummyRunNoRules() throws Exception {
  typeResolver.addImport("org.drools.Cheese");
  List<Field> fieldData = new ArrayList<Field>();
  fieldData.add(new FieldData("type",
      "cheddar"));
  fieldData.add(new FieldData("price",
      "42"));
  FactData fact = new FactData("Cheese",
      "c1",
      fieldData,
      false);
  NewFactPopulator newFactPopulator = new NewFactPopulator(
      populatedData,
      typeResolver,
      Thread.currentThread().getContextClassLoader(),
      fact);
  newFactPopulator.populate(workingMemory, new HashMap<String, FactHandle>());
  assertTrue(populatedData.containsKey("c1"));
  assertNotNull(populatedData.get("c1"));
  assertEquals(populatedData.get("c1"),
      workingMemory.facts.get(0));
}
origin: org.chtijbug.drools/droolsjbpm-ide-common

public FieldData(String name,
         String value) {
  this.setName(name);
  this.setValue(value);
}
origin: org.drools/droolsjbpm-ide-common

@Test
public void testVerifyFactsWithEnum() throws Exception {
  FieldData fieldData = new FieldData(
      "cheeseType",
      "CheeseType.CHEDDAR");
  fieldData.setNature(FieldData.TYPE_ENUM);
  FactData cheeseFactData = new FactData(
      "Cheese",
      false);
  FieldData cheeseType = new FieldData(
      "cheeseType",
      "CheeseType.CHEDDAR"
  );
  cheeseType.setNature(FieldData.TYPE_ENUM);
  FactData f1 = new FactData(
      "Cheese",
origin: org.drools/droolsjbpm-ide-common

@Test
public void testLoadLegacyFieldDataTestScenario() throws Exception {
  StringBuffer contents = new StringBuffer();
  BufferedReader reader = null;
  try {
    reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("LegacyFieldDataTestScenario.xml")));
    String text = null;
    while ((text = reader.readLine()) != null) {
      contents.append(text);
    }
  } catch (Exception e) {
    if (reader != null) {
      reader.close();
    }
    throw new IllegalStateException("Error while reading file.", e);
  }
  Scenario scenario = ScenarioXMLPersistence.getInstance().unmarshal(contents.toString());
  verifyFieldDataNamesAreNotNull(scenario);
  FactData factData = (FactData) scenario.getFixtures().get(0);
  assertTrue(factData.getFieldData().get(0) instanceof CollectionFieldData);
  CollectionFieldData collectionFieldData=(CollectionFieldData)factData.getFieldData().get(0);
  FieldData fieldData = collectionFieldData.getCollectionFieldList().get(0);
  assertEquals("ratingSummaries", fieldData.getName());
  assertEquals("=c1",fieldData.getValue());
}
origin: org.chtijbug.drools/droolsjbpm-ide-common

private String createExpression(CollectionFieldData field) {
  String result = "[";
  int index = 1;
  for (FieldData fieldData : field.getCollectionFieldList()) {
    result += fieldData.getValue().replace("=", "");
    if (index < field.getCollectionFieldList().size()) {
      result += ",";
    }
    index++;
  }
  return result + "]";
}
origin: org.drools/droolsjbpm-ide-common

FieldData fieldData = new FieldData();
fieldData.setName(name);
fieldData.setValue(reader.getValue());
reader.moveUp();
  reader.moveDown();
  String value = reader.getValue();
  fieldData.setNature(Integer.parseInt(value));
  reader.moveUp();
if (fieldData.getValue() != null && fieldData.getValue().startsWith("=[")) {
  CollectionFieldData collectionFieldData = new CollectionFieldData();
  collectionFieldData.setName(name);
  String list = fieldData.getValue().substring(2, fieldData.getValue().length() - 1);
      FieldData subFieldData = new FieldData();
      subFieldData.setName(name);
      subFieldData.setValue(value);
      collectionFieldData.getCollectionFieldList().add(subFieldData);
    FieldData subFieldData = new FieldData();
    subFieldData.setName(name);
    subFieldData.setValue(list);
    collectionFieldData.getCollectionFieldList().add(subFieldData);
origin: org.drools/droolsjbpm-ide-common

"c1",
Arrays.<Field>asList(
    new FieldData(
        "type",
        "cheddar"),
    new FieldData(
        "price",
        "42")),
"p1",
Arrays.<Field>asList(
    new FieldData(
        "name",
        "mic"),
    new FieldData(
        "innerFact",
        "=c1")),
origin: org.chtijbug.drools/droolsjbpm-ide-common

if (fieldData.getValue().startsWith("=")) {
  return new ExpressionFieldPopulator(factObject,
      fieldData.getName(),
      fieldData.getValue().substring(1));
} else if (fieldData.getNature() == FieldData.TYPE_ENUM) {
  return new EnumFieldPopulator(factObject,
      fieldData.getName(),
      fieldData.getValue(),
      typeResolver,
      classLoader);
} else if (isDate(fieldData.getName())) {
  return new DateFieldPopulator(
      factObject,
      getFieldType(fieldData.getName()),
      fieldData.getName(),
      fieldData.getValue());
} else {
  return new SimpleFieldPopulator(factObject,
      fieldData.getName(),
      fieldData.getValue());
origin: org.drools/droolsjbpm-ide-common

public FieldPopulator getFieldPopulator(Field field) throws ClassNotFoundException,
    InstantiationException,
    IllegalAccessException, InvocationTargetException, NoSuchMethodException {
  if (field instanceof FieldData) {
    FieldData fieldData = (FieldData) field;
    if (fieldData.getValue() == null) {
      throw new IllegalArgumentException("Field value can not be null");
    } else {
      return getFieldDataPopulator(factObject,
          fieldData);
    }
  } else if (field instanceof FactAssignmentField) {
    return new FactAssignmentFieldPopulator(factObject,
        (FactAssignmentField) field,
        typeResolver,
        classLoader);
  } else if (field instanceof CollectionFieldData) {
    return new CollectionFieldPopulator(
        factObject,
        (CollectionFieldData) field);
  }
  throw new IllegalArgumentException("Unknown field type " + field.getClass());
}
origin: org.drools/droolsjbpm-ide-common

    "f1",
    Arrays.<Field>asList(
        new FieldData("type",
            ""),
        new FieldData("price",
            "42")),
    false);
    "f2",
    Arrays.<Field>asList(
        new FieldData("type",
            ""),
        new FieldData("price",
            "43")),
    false);
    "f3",
    Arrays.<Field>asList(
        new FieldData("type",
            ""),
        new FieldData("price",
            "45")),
    false);
FieldData field = new FieldData();
field.setName("cheeses");
field.setNature(FieldData.TYPE_COLLECTION);
field.setValue("=[f1,f2,f3]");
List<Field> lstField = new ArrayList<Field>();
origin: org.drools/droolsjbpm-ide-common

"p1",
Arrays.<Field>asList(
    new FieldData(
        "name",
        "mic"),
    new FieldData(
        "innerFact",
        "=c1")),
"c1",
Arrays.<Field>asList(
    new FieldData(
        "type",
        "cheddar"),
    new FieldData(
        "price",
        "42")),
origin: org.chtijbug.drools/droolsjbpm-ide-common

public FieldPopulator getFieldPopulator(Field field) throws ClassNotFoundException,
    InstantiationException,
    IllegalAccessException, InvocationTargetException, NoSuchMethodException {
  if (field instanceof FieldData) {
    FieldData fieldData = (FieldData) field;
    if (fieldData.getValue() == null) {
      throw new IllegalArgumentException("Field value can not be null");
    } else {
      return getFieldDataPopulator(factObject,
          fieldData);
    }
  } else if (field instanceof FactAssignmentField) {
    return new FactAssignmentFieldPopulator(factObject,
        (FactAssignmentField) field,
        typeResolver,
        classLoader);
  } else if (field instanceof CollectionFieldData) {
    return new CollectionFieldPopulator(
        factObject,
        (CollectionFieldData) field);
  }
  throw new IllegalArgumentException("Unknown field type " + field.getClass());
}
org.drools.ide.common.client.modeldriven.testingFieldData

Most used methods

  • <init>
  • getName
  • getValue
  • setName
  • setNature
  • setValue
  • getNature

Popular in Java

  • Parsing JSON documents to java classes using gson
  • scheduleAtFixedRate (ScheduledExecutorService)
  • addToBackStack (FragmentTransaction)
  • setContentView (Activity)
  • Point (java.awt)
    A point representing a location in (x, y) coordinate space, specified in integer precision.
  • MalformedURLException (java.net)
    Thrown to indicate that a malformed URL has occurred. Either no legal protocol could be found in a s
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate(i
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • IsNull (org.hamcrest.core)
    Is the value null?
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now