Package com.denimgroup.threadfix.framework.impl.model

Examples of com.denimgroup.threadfix.framework.impl.model.ModelField


    private void add(String currentModelName, String propertyType, String propertyName) {
        if (!map.containsKey(currentModelName)) {
            map.put(currentModelName, new HashSet<ModelField>());
        }

        map.get(currentModelName).add(new ModelField(propertyType, propertyName));
    }
View Full Code Here


            case START:
                if (type == ARROBA) {
                    setState(SignatureState.ARROBA);
                } else if (stringValue != null && stringValue.equals(BINDING_RESULT) &&
                        lastParamType != null && lastParam != null) {
                    currentModelObject = new ModelField(lastParamType, lastParam); // should be type and variable name
                }
                break;
            case ARROBA:
                if (stringValue != null &&
                        (stringValue.equals(REQUEST_PARAM) || stringValue.equals(PATH_VARIABLE))) {
View Full Code Here

            case IN_ACTION_SIGNATURE:
                if (stringValue != null) {
                    twoStringsAgo = lastString;
                    lastString = stringValue;
                } else if (type == ',' || type == ')' && lastString != null) {
                    parametersWithTypes.add(new ModelField(twoStringsAgo, lastString));
                    if (twoStringsAgo.equals("Include")) {
                        currentState = State.AFTER_BIND_INCLUDE;
                    }
                } else if (type == '=' && !"Include".equals(lastString)) {
                    currentState = State.DEFAULT_VALUE;
View Full Code Here

    List<ModelField> fields = new ArrayList<>();

    if (methodCalls != null && initialField != null) {
      fields.add(initialField);
     
      ModelField currentField = initialField;
      String editedCalls = methodCalls;
     
      if (methodCalls.startsWith(initialField.getParameterKey())) {
        editedCalls = methodCalls.substring(initialField.getParameterKey().length());
      }
     
      String[] calls = editedCalls.split("(\\(\\))");
     
      for (String call : calls) {
        if (call != null && ! call.isEmpty()) {
          String beanAccessor = getParameterFromBeanAccessor(call);
          if (fieldMap.containsKey(currentField.getType()) &&
              fieldMap.get(currentField.getType()).contains(beanAccessor)) {
            ModelField resultField = fieldMap.get(currentField.getType()).getField(beanAccessor);
            if (resultField != null && !resultField.equals(currentField)) {
              fields.add(resultField);
              currentField = resultField;
            }
          } else {
            break;
View Full Code Here

                }
                break;
            case PARAM_TYPE:
                if (currentParamType != null && stringValue != null && stringValue.startsWith("get") &&
                        stringValue.length() > 3) { // this is to avoid errors with methods named "get"
        fieldMappings.add(new ModelField(currentParamType, stringValue));
      }
      state = State.START;
      break;
    }
  }
View Full Code Here

      String modelObject = getModelObject(lines.get(0));
      String initialType = getModelObjectType(lines.get(0));

            if (modelObject != null && initialType != null) {
     
                ModelField beanField = new ModelField(initialType, modelObject);

                List<ModelField> fieldChain = list(beanField);

                for (String elementText : lines) {
                    if (elementText != null) {
                        List<ModelField> beanFields = getParameterWithEntityData(elementText,
                                fieldChain.get(fieldChain.size() - 1));

                        if (beanFields.size() > 1) {
                            beanFields.remove(0);
                            fieldChain.addAll(beanFields);
                            beanField = fieldChain.get(fieldChain.size() - 1);
                        }

                        if (beanField.isPrimitiveType()) {
                            break;
                        }
                    }
                }
View Full Code Here

    SpringEntityParser parser = SpringEntityParser.parse(testFile);
 
  @Test
  public void testBasicFieldEquivalence() {
    assertTrue("These should have been equal.",
        new ModelField("String", "address").equals(new ModelField("String", "address"))
        );
  }
View Full Code Here

  @Test
  public void testOwnerFields() {
    Set<ModelField> fieldMappings = parser.getFieldMappings();
   
    assertTrue("Model missed the address field.",
        fieldMappings.contains(new ModelField("String", "getAddress")));
    assertTrue("Model missed the city field.",
        fieldMappings.contains(new ModelField("String", "getCity")));
    assertTrue("Model missed the telephone field.",
        fieldMappings.contains(new ModelField("String", "getTelephone")));
    assertTrue("Model missed the pet field.",
        fieldMappings.contains(new ModelField("Pet", "getPet")));
  }
View Full Code Here

  public void testMethodChainResolution() {
    File file = new File(TestConstants.PETCLINIC_SOURCE_LOCATION);
    SpringEntityMappings mappings = new SpringEntityMappings(file);
   
    List<ModelField> fields = mappings.getFieldsFromMethodCalls(".getOwner().getLastName()",
        new ModelField("Pet", "pet"));
    assertTrue(fields.get(0).equals(new ModelField("Pet", "pet")));
    assertTrue(fields.get(1).equals(new ModelField("Owner", "owner")));
    assertTrue(fields.get(2).equals(new ModelField("String", "lastName")));
   
    fields = mappings.getFieldsFromMethodCalls(".getOwner()",
        new ModelField("Pet", "pet"));
    assertTrue(fields.get(1).equals(new ModelField("Owner", "owner")));
   
    fields = mappings.getFieldsFromMethodCalls(".getLastName()",
        new ModelField("Owner", "owner"));
    assertTrue(fields.get(1).equals(new ModelField("String", "lastName")));
  }
View Full Code Here

  public void testFakeFile() {
    File file = new File(TestConstants.FAKE_FILE);
    SpringEntityMappings mappings = new SpringEntityMappings(file);
   
    List<ModelField> fields = mappings.getFieldsFromMethodCalls(".getOwner().getLastName()",
        new ModelField("Pet", "pet"));
    assertTrue(fields.get(0).equals(new ModelField("Pet", "pet")));
    assertTrue(fields.size() == 1);
   
    fields = mappings.getFieldsFromMethodCalls(".getOwner()",
        new ModelField("Pet", "pet"));
    assertTrue(fields.size() == 1);
    assertTrue(fields.get(0).equals(new ModelField("Pet", "pet")));
   
    fields = mappings.getFieldsFromMethodCalls(".getLastName()",
        new ModelField("Owner", "owner"));
    assertTrue(fields.size() == 1);
    assertTrue(fields.get(0).equals(new ModelField("Owner", "owner")));
  }
View Full Code Here

TOP

Related Classes of com.denimgroup.threadfix.framework.impl.model.ModelField

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.