Package ro.isdc.wro.model.group

Examples of ro.isdc.wro.model.group.Group


  @Test
  public void testExpandWildcardWithMultipleResources() {
    final WroModel model = new WroModel();
    final String uri = String.format(ClasspathUriLocator.PREFIX + "%s/expander/*.js",
        WroUtil.toPackageAsFolder(getClass()));
    model.addGroup(new Group("group").addResource(Resource.create(uri, ResourceType.JS)));
    Mockito.when(decoratedFactory.create()).thenReturn(model);
   
    final WroModel changedModel = transformer.transform(model);
    LOG.debug("model: {}", changedModel);
    Assert.assertEquals(3, changedModel.getGroupByName("group").getResources().size());
View Full Code Here


  @Test
  public void testExpandWildcardRootDir()
      throws Exception {
    final String uri = "/**.js";
    final Resource resource = Resource.create(uri, ResourceType.JS);
    final Group group = new Group("group").addResource(resource);
   
    final String baseNameFolder = WroUtil.toPackageAsFolder(getClass());
    final Function<Collection<File>, Void> expanderHandler = transformer.createExpanderHandler(group, resource,
        baseNameFolder);
    final File mockFile1 = Mockito.mock(File.class);
    Mockito.when(mockFile1.getPath()).thenReturn(baseNameFolder + "/js1.js");
    final File mockFile2 = Mockito.mock(File.class);
    Mockito.when(mockFile2.getPath()).thenReturn(baseNameFolder + "/js2.js");
   
    expanderHandler.apply(Arrays.asList(mockFile1, mockFile2));
    LOG.debug("group: {}", group);
    Assert.assertEquals(2, group.getResources().size());
    Assert.assertEquals("/js1.js", group.getResources().get(0).getUri());
    Assert.assertEquals("/js2.js", group.getResources().get(1).getUri());
  }
View Full Code Here

  @Test
  public void shouldCorrectlyDetectFilesFromFoldersWithDirectoriesOnlyAsChildren() {
    final WroModel model = new WroModel();
    final String uri = String.format(ClasspathUriLocator.PREFIX + "%s/expander/subfolder/**.js",
        WroUtil.toPackageAsFolder(getClass()));
    model.addGroup(new Group("group").addResource(Resource.create(uri, ResourceType.JS)));
    Mockito.when(decoratedFactory.create()).thenReturn(model);
   
    final WroModel changedModel = transformer.transform(model);
    LOG.debug("model: {}", changedModel);
   
View Full Code Here

  @Test
  public void wildcardResourcesAreOrderedAlphabetically() {
    final WroModel model = new WroModel();
    final String uri = String.format(ClasspathUriLocator.PREFIX + "%s/expander/order/**.js",
        WroUtil.toPackageAsFolder(getClass()));
    model.addGroup(new Group("group").addResource(Resource.create(uri, ResourceType.JS)));
    Mockito.when(decoratedFactory.create()).thenReturn(model);
   
    final WroModel changedModel = transformer.transform(model);
    LOG.debug("model: {}", changedModel);
   
View Full Code Here

  }
 
  @Test
  public void testMinimizeAttributePresence() {
    final WroModel model = loadModelFromLocation("wro-minimizeAttribute.xml");
    final Group group = model.getGroupByName(new WroModelInspector(model).getGroupNames().get(0));
    final List<Resource> resourceList = group.getResources();
    LOG.debug("resources: " + resourceList);
    assertEquals(false, resourceList.get(0).isMinimize());
    assertEquals(true, resourceList.get(1).isMinimize());
    assertEquals(true, resourceList.get(2).isMinimize());
    LOG.debug("model: " + model);
View Full Code Here

    protected WroManagerFactory newWroManagerFactory() {
      final WroManagerFactory factory = super.newWroManagerFactory();
      return new WroManagerFactoryDecorator(factory) {
        @Override
        protected void onBeforeBuild(final Builder builder) {
          final WroModelFactory modelFactory = WroTestUtils.simpleModelFactory(new WroModel().addGroup(new Group("some")));
          builder.setModelFactory(modelFactory);
        }
      };
    }
View Full Code Here

 
  @Test
  public void shouldContainOnlyNonAbstractGroups() {
    final WroModel model = loadModelFromLocation("shouldContainOnlyNonAbstractGroups.xml");
    assertEquals(1, model.getGroups().size());
    final Group group = model.getGroups().iterator().next();
    assertEquals("nonAbstract", group.getName());
    assertEquals(5, group.getResources().size());
  }
View Full Code Here

  /**
   * Instructs the victim to create the model with a single resource
   */
  private void createSampleModel(final String resourceUri) {
    final WroModel model = new WroModel().addGroup(new Group("group").addResource(Resource.create(resourceUri)));
    final WroModelFactory decorated = new WroModelFactory() {
      public WroModel create() {
        return model;
      }

View Full Code Here

  {
    return new WroModelFactory()
    {
      public WroModel create()
      {
        Group dragomeGroup= new Group("dragome");
        dragomeGroup.addResource(Resource.create("/dragome-resources/js/jquery.js", ResourceType.JS)); //TODO extraer constantes
        dragomeGroup.addResource(Resource.create("/dragome-resources/js/hashtable.js", ResourceType.JS));
        dragomeGroup.addResource(Resource.create("/dragome-resources/js/deflate.js", ResourceType.JS));
        dragomeGroup.addResource(Resource.create("/dragome-resources/js/helpers.js", ResourceType.JS));
        dragomeGroup.addResource(Resource.create("/dragome-resources/js/String.js", ResourceType.JS));
        dragomeGroup.addResource(Resource.create("/dragome-resources/js/jquery.atmosphere.js", ResourceType.JS));
        dragomeGroup.addResource(Resource.create("/dragome-resources/js/application.js", ResourceType.JS));
        dragomeGroup.addResource(Resource.create("/dragome-resources/js/q-3.0.js", ResourceType.JS));
        dragomeGroup.addResource(Resource.create("/compiled-js/webapp.js", ResourceType.JS));
        dragomeGroup.addResource(Resource.create("/dragome-resources/css/dragome.css", ResourceType.CSS));

        Group compiledGroup= new Group("compiled");
        compiledGroup.addResource(Resource.create("/compiled-js/webapp.js", ResourceType.JS));

        WroModel wroModel= new WroModel();
        wroModel.addGroup(dragomeGroup);
        wroModel.addGroup(compiledGroup);
View Full Code Here

        // Keep the original group
        map.put(group.getName(), new LinkedHashSet<Resource>(resources));
      }
      WroModel output = new WroModel();
      for (Entry<String, Set<Resource>> g : map.entrySet()) {
        Group newGroup = new Group(g.getKey());
        Set<Resource> resources = g.getValue();
        for (Resource resource : resources) {
          newGroup.addResource(resource);
        }
        output.addGroup(newGroup);
      }
      return output;
    }
View Full Code Here

TOP

Related Classes of ro.isdc.wro.model.group.Group

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.