Package com.mockey.ui

Examples of com.mockey.ui.ServiceMergeResults


    String storeAsXml = getStoreAsXml();

    // ***************************
    // Upload the store again.
    // ***************************
    ServiceMergeResults mergeResults = getMergeResults(storeAsXml);

    // ******************************************************
    // There should be 1 Addition message e.g. 'Proxy set'
    // ******************************************************
    assert (mergeResults.getAdditionMessages().size() == 1) : "Length should have been 1 but was "
        + mergeResults.getAdditionMessages().size()
        + ". Addition messages were: \n"
        + getPrettyPrint(mergeResults.getAdditionMessages());

  }
View Full Code Here


    String storeAsXml = getStoreAsXml();

    // ***************************
    // Upload the store again.
    // ***************************
    ServiceMergeResults mergeResults = getMergeResults(storeAsXml);

    // ******************************************************
    // There should be 1 Conflict messages e.g. 'Service not added because
    // of conflicting name'
    // ******************************************************
    assert (mergeResults.getConflictMsgs().size() == 1) : "Length should have been 1 but was "
        + mergeResults.getConflictMsgs().size()
        + ". Conflict messages were: \n"
        + getPrettyPrint(mergeResults.getConflictMsgs());

  }
View Full Code Here

  }

  private ServiceMergeResults getMergeResults(String storeAsXml) {
    MockeyXmlFileManager.createInstance("");
    MockeyXmlFileManager configurationReader = MockeyXmlFileManager.getInstance();
    ServiceMergeResults mergeResults = null;
    try {
      mergeResults = configurationReader.loadConfigurationWithXmlDef(
          storeAsXml, "");

    } catch (SAXParseException e) {
View Full Code Here

      return loadConfigurationWithXmlDef(getFileContentAsString(new FileInputStream(n)), null);
    } catch (SAXException e) {
      logger.error("Ouch, unable to parse" + n.getAbsolutePath(), e);
    }
    return new ServiceMergeResults();
  }
View Full Code Here

   * @throws SAXParseException
   * @throws SAXException
   */
  public ServiceMergeResults loadConfigurationWithXmlDef(String strXMLDefintion, String tagArguments)
      throws IOException, SAXParseException, SAXException {
    ServiceMergeResults mergeResults = new ServiceMergeResults();

    // ***** REMEMBER *****
    // Every time a saveOrUpdateXXXX is made, the entire STORE is written to
    // the file system.
    // If the STORE has many definitions, then each SAVE will loop over
    // every file and write.
    //
    // NOT GOOD FOR PERFORMANCE
    //
    // Solution: put the store in a temporary transient state
    // (memory-mode-only), then revert to original transient setting,
    // which could have been in memory-only or write-to-file in the
    // first place.
    //
    // *********************
    Boolean originalTransientState = store.getReadOnlyMode();
    store.setReadOnlyMode(true);

    // STEP #1. CREATE A TEMP STORE
    // Read the incoming XML file, and create a new/temporary store for the
    // need to ensure current store doesn't get overridden
    //
    MockeyXmlFileConfigurationReader msfr = new MockeyXmlFileConfigurationReader();
    IMockeyStorage mockServiceStoreTemporary = msfr.readDefinition(strXMLDefintion);

    // STEP #2. PROXY SETTINGS
    // If the proxy settings are _empty_, then set the incoming
    // proxy settings. Otherwise, call out a merge conflict.
    //
    ProxyServerModel proxyServerModel = store.getProxy();
    if (proxyServerModel.hasSettings()) {
      mergeResults.addConflictMsg("Proxy settings NOT set from incoming file.");
    } else {
      store.setProxy(mockServiceStoreTemporary.getProxy());
      mergeResults.addAdditionMsg("Proxy settings set.");
    }

    // STEP #3. BUILD SERVICE REFERENCES
    // Why is this needed?
    // We are adding _new_ services into the Store, and that means that the
    // store's state is always changing. We need references as a saved
    // snapshot list of store state prior to adding new services.
    // **********
    // I forget why we really need this though...
    // **********
    List<Service> serviceListFromRefs = new ArrayList<Service>();
    for (ServiceRef serviceRef : mockServiceStoreTemporary.getServiceRefs()) {
      try {

        String mockServiceDefinition = getFileContentAsString(new FileInputStream(serviceRef.getFileName()));

        // HACK:
        // I tried to find an easier way to use XML ENTITY and let
        // Digester
        // to the work of slurping up the XML but was unsuccessful.
        // Hence, the brute force.
        // YYYYY
        //

        List<Service> tmpList = msfr.readServiceDefinition(mockServiceDefinition);
        for (Service tmpService : tmpList) {
          serviceListFromRefs.add(tmpService);
        }
      } catch (SAXParseException spe) {
        logger.error("Unable to parse file of name " + serviceRef.getFileName(), spe);
        mergeResults.addConflictMsg("File not parseable: " + serviceRef.getFileName());

      } catch (FileNotFoundException fnf) {
        logger.error("File not found: " + serviceRef.getFileName());
        mergeResults.addConflictMsg("File not found: " + serviceRef.getFileName());
      }

    }
    addServicesToStore(mergeResults, serviceListFromRefs, tagArguments);

    // STEP #4. MERGE SERVICES AND SCENARIOS
    // Since this gets complicated, logic was moved to it's own method.
    mergeResults = addServicesToStore(mergeResults, mockServiceStoreTemporary.getServices(), tagArguments);

    // STEP #5. UNIVERSAL RESPONSE SETTINGS
    // Important: usage of the temporary-store's Scenario reference
    // information is used to set the primary in-memory store. The primary
    // store has all the information and the TEMP store only needs to pass
    // the references, e.g. Service 1, Scenario 2.
    if (store.getUniversalErrorScenario() != null
        && mockServiceStoreTemporary.getUniversalErrorScenarioRef() != null) {
      mergeResults.addConflictMsg("Universal error message already defined with name '"
          + store.getUniversalErrorScenario().getScenarioName() + "'");
    } else if (store.getUniversalErrorScenario() == null
        && mockServiceStoreTemporary.getUniversalErrorScenarioRef() != null) {
      store.setUniversalErrorScenarioRef(mockServiceStoreTemporary.getUniversalErrorScenarioRef());
      mergeResults.addAdditionMsg("Universal error response defined.");

    }

    // STEP #6. MERGE SERVICE PLANS
    for (ServicePlan servicePlan : mockServiceStoreTemporary.getServicePlans()) {
View Full Code Here

      // #TAG HANDLING for the Service - END
      // ********************** TAG - END *****************

      // ********************* SCENARIOS BEGIN *******************
      if (readResults == null) {
        readResults = new ServiceMergeResults();
      }

      Iterator<Scenario> uploadedListIter = uploadedService.getScenarios().iterator();
      Iterator<Scenario> inMemListIter = inMemoryService.getScenarios().iterator();

View Full Code Here

TOP

Related Classes of com.mockey.ui.ServiceMergeResults

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.