Package com.sandwich.koan.path.PathToEnlightenment

Examples of com.sandwich.koan.path.PathToEnlightenment.Path


  @Override
  public Path transform(){
    Map<String, Map<String, Map<String, KoanElementAttributes>>> koans =
      new LinkedHashMap<String, Map<String, Map<String, KoanElementAttributes>>>();
    koans.put("test", new LinkedHashMap<String, Map<String, KoanElementAttributes>>(methodsBySuite));
    return new Path(null,koans);
  }
View Full Code Here


    assertSame(originalConsole, System.out);
  }
 
  @Test
  public void testThatStubAllKoansStubsAllKoansReference() throws Exception {
    Path oldKoans = PathToEnlightenment.getPathToEnlightenment();
    List<Object> newKoans = Collections.emptyList();
    testCase.stubAllKoans(newKoans);
    assertNotSame(oldKoans, PathToEnlightenment.getPathToEnlightenment());
    // number of suites
    assertEquals(0, PathToEnlightenment.getPathToEnlightenment()
View Full Code Here

        .iterator().next().getValue().size());
  }
 
  @Test
  public void testTestCaseRestoresAllKoansReference() throws Exception {
    Path oldKoans = PathToEnlightenment.getPathToEnlightenment();
    List<Object> newKoans = Collections.emptyList();
    testCase.stubAllKoans(newKoans);
    assertNotSame(oldKoans, PathToEnlightenment.getPathToEnlightenment());
    testCase.tearDown();
    // creates all new instance
View Full Code Here

      f.setAccessible(isAccessible);
    }
  }
 
  protected Path stubAllKoans(String packageName, List<String> path){
    Path oldKoans = PathToEnlightenment.getPathToEnlightenment();
    Map<String, Map<String, KoanElementAttributes>> tempSuitesAndMethods =
      new LinkedHashMap<String, Map<String, KoanElementAttributes>>();
    DynamicClassLoader loader = KoanClassLoader.getInstance();
    for(String suite : path){
      Map<String, KoanElementAttributes> methodsByName = new LinkedHashMap<String, KoanElementAttributes>();
      KoanSuiteCompilationListener listener = new KoanSuiteCompilationListener();
      for(Method m : loader.loadClass(suite, listener).getMethods()){
        if(m.getAnnotation(Koan.class) != null){
          methodsByName.put(m.getName(), new KoanElementAttributes(m.getName(), "", m.getDeclaringClass().getName()));
        }
      }
      tempSuitesAndMethods.put(suite, methodsByName);
    }
    Map<String, Map<String, Map<String, KoanElementAttributes>>> stubbedPath =
      new LinkedHashMap<String, Map<String, Map<String, KoanElementAttributes>>>();
    stubbedPath.put(packageName, tempSuitesAndMethods);
    PathToEnlightenment.theWay = new Path(null,stubbedPath);
    return oldKoans;
  }
View Full Code Here

    List<String> passingSuites = new ArrayList<String>();
    List<String> failingSuites = new ArrayList<String>();
    String level = null;
    KoanMethodResult failure = null;
    DynamicClassLoader loader = KoanClassLoader.getInstance();
    Path pathToEnlightenment = getPathToEnlightenment();
    KoanSuiteCompilationListener compilationListener = new KoanSuiteCompilationListener();
    int successfull = 0;
    for (Entry<String, Map<String, Map<String, KoanElementAttributes>>> packages : pathToEnlightenment) {
      for (Entry<String, Map<String, KoanElementAttributes>> e : packages.getValue().entrySet()) {
        String name = e.getKey().substring(e.getKey().lastIndexOf('.')+1);
        if(failure == null){
          Object suite = safelyConstructSuite(loader, compilationListener, e);
          final List<KoanElementAttributes> attributes = new ArrayList<KoanElementAttributes>(e.getValue().values());
          final List<KoanMethod> methods = mergeJavaFilesMethodsAndThoseInXml(suite, attributes, pathToEnlightenment.getOnlyMethodNameToRun());
          Collections.sort(methods, new KoanComparator());
          for (final KoanMethod koan : methods) {
            KoanMethodResult result = KoanMethodRunner.run(suite, koan);
            if(KoanMethodResult.PASSED != result){
              // Test failed!
              failure = result;
              failingSuites.add(name);
              break;
            }else{
              successfull++;
            }
          }
          if (failure == null) {
            passingSuites.add(name);
          }
          level = packages.getKey();
        }else{
          failingSuites.add(name);
        }
      }
    }
    return new KoanResultBuilder()
        .level(level)
        .numberPassing(successfull)
        .totalNumberOfKoanMethods(pathToEnlightenment.getTotalNumberOfKoans())
        .methodResult(failure).passingCases(passingSuites)
        .remainingCases(failingSuites).build();
  }
View Full Code Here

    PathToEnlightenment.xmlToPathTransformer = null;
    PathToEnlightenment.theWay = PathToEnlightenment.createPath();
  }
 
  protected Path stubAllKoans(String packageName, List<String> path){
    Path oldKoans = PathToEnlightenment.getPathToEnlightenment();
    Map<String, Map<String, KoanElementAttributes>> tempSuitesAndMethods =
      new LinkedHashMap<String, Map<String, KoanElementAttributes>>();
    DynamicClassLoader loader = new DynamicClassLoader();
    for(String suite : path){
      Map<String, KoanElementAttributes> methodsByName = new LinkedHashMap<String, KoanElementAttributes>();
      for(Method m : loader.loadClass(suite).getMethods()){
        if(m.getAnnotation(Koan.class) != null){
          methodsByName.put(m.getName(), new KoanElementAttributes("", m.getName(), "", m.getDeclaringClass().getName()));
        }
      }
      tempSuitesAndMethods.put(suite, methodsByName);
    }
    Map<String, Map<String, Map<String, KoanElementAttributes>>> stubbedPath =
      new LinkedHashMap<String, Map<String, Map<String, KoanElementAttributes>>>();
    stubbedPath.put(packageName, tempSuitesAndMethods);
    PathToEnlightenment.theWay = new Path(null,stubbedPath);
    return oldKoans;
  }
View Full Code Here

        Node node = nodeLst.item(i);
        String packageTitle = node.getAttributes().getNamedItem("name").getNodeValue();
        String pkg = node.getAttributes().getNamedItem("pkg").getNodeValue();
        koans.put(packageTitle, getKoanElementAttributesByMethodNameBySuite(pkg, node.getChildNodes()));
      }
      return new Path(methodName, koans);
    }catch(Exception x){
      throw new RuntimeException(x);
    }
  }
View Full Code Here

    assertSame(originalConsole, System.out);
  }
 
  @Test
  public void testThatStubAllKoansStubsAllKoansReference() throws Exception {
    Path oldKoans = PathToEnlightenment.getPathToEnlightenment();
    List<Object> newKoans = Collections.emptyList();
    testCase.stubAllKoans(newKoans);
    assertNotSame(oldKoans, PathToEnlightenment.getPathToEnlightenment());
    // number of suites
    assertEquals(0, PathToEnlightenment.getPathToEnlightenment()
View Full Code Here

        .iterator().next().getValue().size());
  }
 
  @Test
  public void testTestCaseRestoresAllKoansReference() throws Exception {
    Path oldKoans = PathToEnlightenment.getPathToEnlightenment();
    List<Object> newKoans = Collections.emptyList();
    testCase.stubAllKoans(newKoans);
    assertNotSame(oldKoans, PathToEnlightenment.getPathToEnlightenment());
    testCase.tearDown();
    // creates all new instance
View Full Code Here

TOP

Related Classes of com.sandwich.koan.path.PathToEnlightenment.Path

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.