Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 1&1 Internet AG, https://github.com/1and1/ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package net.oneandone.jasmin.model;
 
 import org.junit.Test;
 
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 public class RepositoryTest {
     private World world;
     private Repository repository;
 
     @Before
     public void before() throws IOException {
          = new World();
          = Repository.load(new Resolver());
     }
 
     @Test
     public void builtIn() {
         .get("jasmin-labjs");
     }
 
     @Test(expected = RuntimeException.class)
     public void notFound() throws Exception {
         .get("notfound");
     }
 
     @Test
     public void auto() {
         Module module;
         File file;
 
         module = .get("jasmin-auto-auto1");
         assertNotNull(module);
         assertEquals(2, module.files().size());
         file = module.files().get(0);
         if (!file.getNormal().getName().endsWith("auto1.js")) {
             module.files().remove(0);
             module.files().add(file);
             file = module.files().get(0);
         }
         assertTrue(""file.getNormal().getName().endsWith("auto1.js"));
         assertTrue(""file.getMinimized().getName().endsWith("auto1-min.js"));
         assertNull(file.getVariant());
         file = module.files().get(1);
         assertEquals("foo"file.getVariant());
 
         module = .get("jasmin-auto-sub-auto2");
         assertEquals(Arrays.asList(.get("jasmin-auto-auto1")), module.dependencies());
         assertEquals(1, module.files().size());
         file = module.files().get(0);
         assertTrue(file.getNormal().getPath().endsWith("auto/sub/auto2.js"));
 
         module = .get("jasmin-auto-sub-only");
         assertEquals(1, module.files().size());
         file = module.files().get(0);
         assertEquals(file.getNormal(), file.getMinimized());
     }
 
     @Test
     public void get() throws Exception {
         Module group;
 
         group = .get("foo");
         assertEquals("foo"group.getName());
     }
 
     @Test
     public void sequenceOne() throws Exception {
         assertEquals(Arrays.asList("sub.bar""foo"), .sequence("foo"));
     }
 
     @Test
     public void sequenceFirstAsFirst() throws Exception {
         assertEquals(Arrays.asList("two""sub.bar""foo"), .sequence("two""foo"));
    }
    @Test
    public void sequenceLastAsLast() throws Exception {
        assertEquals(Arrays.asList("sub.bar""foo""two"), .sequence("foo""two"));
    }
    @Test
    public void resolveOne() throws Exception {
        check("foo/css/x""my.css");
    }
    @Test
    public void resolveTwo() throws Exception {
        check("sub.bar+foo/css/x""my.css");
    }
    @Test(expected = CyclicDependency.class)
    public void resolveDuplicate() throws Exception {
        check("foo+foo/css/x""my.css");
    }
    private void check(String requestString... expectedthrows Exception {
        References references;
        references = .resolve(Request.parse(request));
        assertEquals("expected " + Strings.toList(expected) + ", go " + referencesexpected.lengthreferences.nodes.size());
        for (int i = 0; i < expected.lengthi++) {
            assertEquals(expected[i], references.nodes.get(i).getName());
        }
    }
New to GrepCode? Check out our FAQ X