Package com.mockey.model

Examples of com.mockey.model.Service


 
  @Test
  public void validateServiceScenarioFile(){
   
    MockeyXmlFileManager.createInstance(TESTCONFIG_DIR);
    Service feelingService = new Service();
    feelingService.setServiceName("feeling");
    feelingService.setUrl("/feeling");
    Scenario happyScenario = new Scenario();
    happyScenario.setScenarioName("happy");
    happyScenario.setResponseMessage("HAPPY");
    happyScenario = feelingService.saveOrUpdateScenario(happyScenario);
    File scenarioFile = MockeyXmlFileManager.getInstance().getServiceScenarioFileAbsolutePath(feelingService, happyScenario);
    assert(scenarioFile!=null) : "Scenario is null. It should not be."
    String correctPath  = TESTCONFIG_DIR + File.separator + "mockey_def_depot" +File.separator +"feeling" + File.separator +"scenarios" + File.separator +"happy.xml";
    assert(scenarioFile.getAbsolutePath().equals(correctPath)) : "Invalid scenario file path.  \n    WAS:" + scenarioFile.getAbsolutePath() +"\nCORRECT:" + correctPath;
   
View Full Code Here


 
  @Test
  public void validateServiceFileWithNewBasePath() {
    MockeyXmlFileManager.createInstance(TESTCONFIG_DIR);
   
    Service s = new Service();
    s.setServiceName("a_service_name");
    File x = MockeyXmlFileManager.getInstance().getServiceFile(s);
    // Path should be.."/Users/clafonta/Work/Mockey/dist/test/mockey_def_depot/a_service_name/a_service_name.xml".
    String path = TESTCONFIG_DIR +  File.separator + "mockey_def_depot" + File.separator +"a_service_name" + File.separator + "a_service_name.xml";
   
   
View Full Code Here

    store.deleteEverything();

    // ***************************
    // New Store
    // ***************************
    Service service = new Service();
    service.setServiceName("Service 1");
    service.setTag("abc");
    service.saveOrUpdateRealServiceUrl(new Url("http://www.abc.com"));

    store.saveOrUpdateService(service);

    // ***************************
    // Get the store as XML
    // ***************************
    String storeAsXml = getStoreAsXml();

    // ***************************
    // Rebuild the store with:
    // - Same Service
    // - Different URL
    // ***************************
    store.deleteEverything();
    service = new Service();
    service.setServiceName("Service 1");
    service.setTag("def");

    service.saveOrUpdateRealServiceUrl(new Url("http://www.def.com"));

    store.saveOrUpdateService(service);

    // ***************************
    // Upload/Merge the store again.
    // Result should be 1 Service in the store with 2 Real URLS (merged)
    // ***************************
    getMergeResults(storeAsXml);

    // ******************************************************
    // There should be 1 Conflict messages e.g. 'Service not added because
    // of conflicting name'
    // ******************************************************
    List<Service> storeServices = store.getServices();
    assert (storeServices.size() == 1) : "Number of Services in the Store should have been 1 but was "
        + storeServices.size();

    Service serviceToTest = storeServices.get(0);
    assert (serviceToTest.getRealServiceUrls().size() == 2) : "Number of Real URLS in the Service should have been 2 but was "
        + serviceToTest.getRealServiceUrls().size();

  }
View Full Code Here

    store.deleteEverything();

    // ***************************
    // New Store
    // ***************************
    Service service = new Service();
    service.setServiceName("Service 1");
    service.setTag("abc");
    store.saveOrUpdateService(service);

    // ***************************
    // Get the store as XML
    // ***************************
    String storeAsXml = getStoreAsXml();

    // ***************************
    // Rebuild the store with:
    // - Same Service
    // - Different URL
    // ***************************
    store.deleteEverything();
    service = new Service();
    service.setServiceName("Service 1");
    service.setTag("def");
    store.saveOrUpdateService(service);

    // ***************************
    // Upload/Merge the store again.
    // Result should be 1 Service in the store with 2 Real URLS (merged)
    // ***************************
    getMergeResults(storeAsXml);

    List<Service> storeServices = store.getServices();
    assert (storeServices.size() == 1) : "Number of Services in the Store should have been 1 but was "
        + storeServices.size();
    Service serviceToTest = storeServices.get(0);
    assert (serviceToTest.getTagList().size() == 2) : "Number of Tags in the Service should have been size 2, with value 'abc def' but was size "
        + serviceToTest.getTagList().size()
        + " with value '"
        + serviceToTest.getTag() + "'";

  }
View Full Code Here

    store.deleteEverything();

    // ***************************
    // New Store
    // ***************************
    Service service = new Service();
    service.setServiceName("Service 1");
    Scenario scenario = new Scenario();
    scenario.setScenarioName("ABC");
    scenario.setTag("abc");
    service.saveOrUpdateScenario(scenario);
    store.saveOrUpdateService(service);

    // ***************************
    // Get the store as XML
    // ***************************
    String storeAsXml = getStoreAsXml();

    // ***************************
    // Rebuild the store with:
    // - Same Service, same scenario
    // - Service scenario has different tag
    // ***************************
    store.deleteEverything();
    service = new Service();
    service.setServiceName("Service 1");
    scenario = new Scenario();
    scenario.setScenarioName("ABC");
    scenario.setTag("def");
    service.saveOrUpdateScenario(scenario);
    store.saveOrUpdateService(service);

    // ***************************
    // Upload/Merge the store again.
    // Result should be 1 Service in the store with 2 Real URLS (merged)
    // ***************************
    getMergeResults(storeAsXml);

    List<Service> storeServices = store.getServices();
    assert (storeServices.size() == 1) : "Number of Services in the Store should have been 1 but was "
        + storeServices.size();
    Service serviceToTest = storeServices.get(0);
    List<Scenario> scenarioList = serviceToTest.getScenarios();
    assert (scenarioList.size() == 1) : "Number of Service scenarios in the Store should have been 1 but was "
        + scenarioList.size()
        + " with value: \n"
        + getScenarioListAsString(scenarioList);

View Full Code Here

  public void checkForRelativePath() {
    File randomFile = new File(File.separator + "makebelieve" + File.separator + "somenewfile");
    File seedFile = new File(File.separator + "seed");
    MockeyXmlFileManager.createInstance(seedFile.getAbsolutePath());
    MockeyXmlFileManager mxfm = MockeyXmlFileManager.getInstance();
    Service s = new Service();
    s.setServiceName("AnAccountService");
    File serviceFile = MockeyXmlFileManager.getInstance().getServiceFile(s);
    assert (("mockey_def_depot" +File.separator +"anaccountservice"+File.separator+"anaccountservice.xml").equals(mxfm.getRelativePath(serviceFile))) : "Fail in catching invalid child file path. Expected '"
      + "mockey_def_depo"+File.separator+"anaccountservice"+File.separator+"anaccountservice.xml' but got '"+mxfm.getRelativePath(serviceFile)+"'";
    assert ("ERROR".equals(mxfm.getRelativePath(randomFile))) : "Fail in catching BAD file.";
  }
View Full Code Here

    store.deleteEverything();

    // ***************************
    // New Store
    // ***************************
    Service service = new Service();
    service.setServiceName("Service 1");
    store.saveOrUpdateService(service);

    // ***************************
    // Get the store as XML
    // ***************************
 
View Full Code Here

  }

  private List<Service> getServiceList() {
    List<Service> serviceList = new ArrayList<Service>();

    Service service = new Service();
    service.setServiceName("Service 1");
    service.saveOrUpdateRealServiceUrl(new Url("http://www.abc.com"));
    service.saveOrUpdateRealServiceUrl(new Url("http://www.nbc.com"));
    serviceList.add(service);

    Service serviceB = new Service();
    serviceB.setServiceName("Service 22");
    serviceB.saveOrUpdateRealServiceUrl(new Url("http://www.abc.com"));
    serviceB.saveOrUpdateRealServiceUrl(new Url("http://www.nbc.com"));
    serviceList.add(serviceB);
    return serviceList;
  }
View Full Code Here

   */
  @Test
  public void validateSearchResultByName() {

    IMockeyStorage store = new InMemoryMockeyStorage();
    Service a = new Service();
    a.setServiceName("Service A");
    Scenario aScenario = new Scenario();
    aScenario.setScenarioName("Service Scenario A");
    a.saveOrUpdateScenario(aScenario);
    store.saveOrUpdateService(a);

    String term = "scenario";
    SearchResultBuilder resultBuilder = new SearchResultBuilder();
    List<SearchResult> resultList = resultBuilder.buildSearchResults(term,
View Full Code Here

   */
  @Test
  public void validateSearchResultScenarioContent() {

    IMockeyStorage store = new InMemoryMockeyStorage();
    Service a = new Service();
    a.setServiceName("Service A");
    Scenario aScenario = new Scenario();
    aScenario.setScenarioName("Scenario A");
    aScenario.setResponseMessage("lorem ipsum");
    a.saveOrUpdateScenario(aScenario);
    store.saveOrUpdateService(a);

    String term = "cats";
    SearchResultBuilder resultBuilder = new SearchResultBuilder();
    List<SearchResult> resultList = resultBuilder.buildSearchResults(term,
        store);

    assert (resultList.size() == 0) : "Length should be 0 but was "
        + resultList.size();

    term = "  lorem   ";
    resultBuilder = new SearchResultBuilder();
    resultList = resultBuilder.buildSearchResults(term, store);
    assert (resultList.size() == 1) : "Length should be: 1 " + " but was '"
        + resultList.size() + "'";
    assert (resultList.get(0).getType() == SearchResultType.SERVICE_SCENARIO) : "Search type result should be 'scenario' but was '"
        + resultList.get(0).getType().toString() + "'";

    aScenario = new Scenario();
    aScenario.setScenarioName("Scenario B");
    aScenario.setResponseMessage("lorem ipsula");
    a.saveOrUpdateScenario(aScenario);
    store.saveOrUpdateService(a);

    term = "  lorem   ";
    resultBuilder = new SearchResultBuilder();
    resultList = resultBuilder.buildSearchResults(term, store);
View Full Code Here

TOP

Related Classes of com.mockey.model.Service

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.