Package ro.isdc.wro.model.group

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


    assertEquals(buildValidModel(), victim);
  }

  @Test
  public void shouldMergeNotEmptyModel() {
    victim.merge(new WroModel().addGroup(new Group("anEmptyGroup")));
    assertEquals(Arrays.asList("anEmptyGroup", "g1", "g2", "g3"), new WroModelInspector(victim).getGroupNames());
  }
View Full Code Here


    final WroModel model = new WroModel();
    victim = new WroModelInspector(model);

    assertEquals(0, victim.getAllUniqueResources().size());

    model.addGroup(new Group("one").addResource(Resource.create("/one.js"))).addGroup(
        new Group("two").addResource(Resource.create("/one.js")));
    //should still be zero, even if the model changed
    assertEquals(0, victim.getAllUniqueResources().size());
    assertEquals(1, new WroModelInspector(model).getAllUniqueResources().size());
    assertEquals(2, new WroModelInspector(model).getAllResources().size());
  }
View Full Code Here

   
    final GroupExtractor groupExtractor = Mockito.mock(GroupExtractor.class);
    Mockito.when(groupExtractor.getGroupName(Mockito.any(HttpServletRequest.class))).thenReturn(groupName);
    Mockito.when(groupExtractor.getResourceType(Mockito.any(HttpServletRequest.class))).thenReturn(ResourceType.JS);
   
    final Group group = new Group(groupName);
    group.addResource(Resource.create("classpath:1.js"));
    final WroModelFactory modelFactory = WroUtil.factoryFor(new WroModel().addGroup(group));
   
    final WroManagerFactory managerFactory = new BaseWroManagerFactory().setGroupExtractor(groupExtractor).setModelFactory(
        modelFactory);
    final WroManager manager = managerFactory.create();
View Full Code Here

    notNull(cacheKey);
    LOG.debug("started");
    final StopWatch watch = new StopWatch();
    watch.start("detect changes");
    try {
      final Group group = new WroModelInspector(modelFactory.create()).getGroupByName(cacheKey.getGroupName());
      if (isGroupChanged(group.collectResourcesOfType(cacheKey.getType()), callback)) {
        callback.onGroupChanged(cacheKey);
        cacheStrategy.put(cacheKey, null);
      }
      resourceChangeDetector.reset();
    } catch (final Exception e) {
View Full Code Here

    try {
      LOG.debug("Starting processing group [{}] of type [{}] with minimized flag: " + cacheKey.isMinimize(),
          cacheKey.getGroupName(), cacheKey.getType());
      // find processed result for a group
      final WroModel model = modelFactory.create();
      final Group group = new WroModelInspector(model).getGroupByName(cacheKey.getGroupName());
      if (group == null) {
        throw new WroRuntimeException("No such group available in the model: " + cacheKey.getGroupName());
      }
      final Group filteredGroup = group.collectResourcesOfType(cacheKey.getType());
      if (filteredGroup.getResources().isEmpty()) {
        LOG.debug("No resources found in group: {} and resource type: {}", group.getName(), cacheKey.getType());
        if (!context.getConfig().isIgnoreEmptyGroup()) {
          throw new WroRuntimeException("No resources found in group: " + group.getName());
        }
      }
      final String result = preProcessorExecutor.processAndMerge(filteredGroup.getResources(), cacheKey.isMinimize());
      return applyPostProcessors(cacheKey, result);
    } catch (final IOException e) {
      throw new WroRuntimeException("Exception while merging resources: " + e.getMessage(), e).logError();
    } finally {
      callbackRegistry.onProcessingComplete();
View Full Code Here

          });
        };

        @Override
        protected WroModelFactory newModelFactory() {
          return WroTestUtils.simpleModelFactory(new WroModel().addGroup(new Group("group").addResource(resource)));
        }
      };
    }
View Full Code Here

    // have to reset it, otherwise a test fails when testing entire project.
    Mockito.reset(mockResourceWatcher);
  }

  public Injector createInjector() {
    final WroModel model = new WroModel().addGroup(new Group(GROUP_NAME).addResource(Resource.create(RESOURCE_URI)));
    final WroModelFactory modelFactory = WroTestUtils.simpleModelFactory(model);
    final UriLocatorFactory locatorFactory = WroTestUtils.createResourceMockingLocatorFactory();
    final BaseWroManagerFactory factory = new BaseWroManagerFactory().setModelFactory(modelFactory).setUriLocatorFactory(
        locatorFactory);
    factory.setProcessorsFactory(new SimpleProcessorsFactory());
View Full Code Here

          + ". Recursion path: " + groupsInProcess);
    }
    LOG.debug("\tadding group: {}", name);
    groupsInProcess.add(name);
    // skip if this group is already parsed
    final Group parsedGroup = new WroModelInspector(model).getGroupByName(name);
    if (parsedGroup != null) {
      // remove before returning
      // this group is parsed, remove from unparsed groups collection
      groupsInProcess.remove(name);
      return parsedGroup.getResources();
    }
    final Group group = new Group(name);
    final List<Resource> resources = new ArrayList<Resource>();
    final NodeList resourceNodeList = element.getChildNodes();
    for (int i = 0; i < resourceNodeList.getLength(); i++) {
      final Node node = resourceNodeList.item(i);
      if (node instanceof Element) {
        final Element resourceElement = (Element) node;
        parseResource(resourceElement, resources);
      }
    }
    group.setResources(resources);
    // this group is parsed, remove from unparsed collection
    groupsInProcess.remove(name);
    if (!isAbstractGroup) {
      // add only non abstract groups
      model.addGroup(group);
View Full Code Here

  /**
   * Search for all resources for a group with a given name.
   */
  private Collection<Resource> getResourcesForGroup(final String groupName) {
    final WroModelInspector modelInspector = new WroModelInspector(model);
    final Group foundGroup = modelInspector.getGroupByName(groupName);
    if (foundGroup == null) {
      Collection<Resource> groupResources = null;
      final Element groupElement = allGroupElements.get(groupName);
      if (groupElement == null) {
        throw new WroRuntimeException("Invalid group-ref: " + groupName);
      }
      groupResources = parseGroup(groupElement);
      return groupResources;
    }
    return foundGroup.getResources();
  }
View Full Code Here

   * @deprecated use {@link WroModelInspector#getGroupByName(String)}
   */
  @Deprecated
  public Group getGroupByName(final String name) {
    final WroModelInspector modelInspector = new WroModelInspector(this);
    final Group group = modelInspector.getGroupByName(name);
    if (group == null) {
      throw new InvalidGroupNameException(String.format("There is no such group: '%s'. Available groups are: [%s]", name,
          modelInspector.getGroupNamesAsString()));
    }
    return group;
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.