The following document contains the results of PMD's CPD 6.55.0.

Duplications

File Project Line
io/wcm/testing/mock/aem/junit/AemContextBuilder.java AEM Mocks JUnit 4 64
io/wcm/testing/mock/aem/junit5/AemContextBuilder.java AEM Mocks JUnit 5 64
return this;
  }

  /**
   * @param plugin Context plugin which listens to context lifecycle events.
   * @return this
   */
  @SafeVarargs
  public final @NotNull AemContextBuilder plugin(@NotNull ContextPlugin<? extends OsgiContextImpl> @NotNull... plugin) {
    plugins.addPlugin(plugin);
    return this;
  }

  /**
   * @param beforeSetUpCallback Allows the application to register an own callback function that is called before the
   *          built-in setup rules are executed.
   * @return this
   */
  @SafeVarargs
  public final @NotNull AemContextBuilder beforeSetUp(@NotNull ContextCallback<? extends OsgiContextImpl> @NotNull... beforeSetUpCallback) {
    plugins.addBeforeSetUpCallback(beforeSetUpCallback);
    return this;
  }

  /**
   * @param afterSetUpCallback Allows the application to register an own callback function that is called after the
   *          built-in setup rules are executed.
   * @return this
   */
  @SafeVarargs
  public final @NotNull AemContextBuilder afterSetUp(@NotNull ContextCallback<? extends OsgiContextImpl> @NotNull... afterSetUpCallback) {
    plugins.addAfterSetUpCallback(afterSetUpCallback);
    return this;
  }

  /**
   * @param beforeTearDownCallback Allows the application to register an own callback function that is called before the
   *          built-in teardown rules are executed.
   * @return this
   */
  @SafeVarargs
  public final @NotNull AemContextBuilder beforeTearDown(@NotNull ContextCallback<? extends OsgiContextImpl> @NotNull... beforeTearDownCallback) {
    plugins.addBeforeTearDownCallback(beforeTearDownCallback);
    return this;
  }

  /**
   * @param afterTearDownCallback Allows the application to register an own callback function that is after before the
   *          built-in teardown rules are executed.
   * @return this
   */
  @SafeVarargs
  public final @NotNull AemContextBuilder afterTearDown(@NotNull ContextCallback<? extends OsgiContextImpl> @NotNull... afterTearDownCallback) {
    plugins.addAfterTearDownCallback(afterTearDownCallback);
    return this;
  }

  /**
   * Allows to override OSGi configuration parameters for the Resource Resolver Factory Activator service.
   * @param props Configuration properties
   * @return this
   */
  public @NotNull AemContextBuilder resourceResolverFactoryActivatorProps(@NotNull Map<String, Object> props) {
    this.resourceResolverFactoryActivatorProps = props;
    return this;
  }

  /**
   * Automatic registering of all Sling Models found in the classpath on startup (active by default).
   * @param value If set to false Sling Models are not registered automatically from the classpath on startup.
   * @return this
   */
  public @NotNull AemContextBuilder registerSlingModelsFromClassPath(boolean value) {
    this.registerSlingModelsFromClassPath = value;
    return this;
  }

  /**
   * @return Build {@link AemContext} instance.
   */
  public @NotNull AemContext build() {
    return new AemContext(this.plugins,
        this.resourceResolverFactoryActivatorProps,
        this.registerSlingModelsFromClassPath,
        this.resourceResolverTypes);
File Project Line
io/wcm/testing/mock/aem/MockContentFragment_ContentVariation_Structured.java AEM Mocks Core 111
io/wcm/testing/mock/aem/MockContentFragment_ContentVariation_Text.java AEM Mocks Core 108
public void setValue(FragmentData arg0) throws ContentFragmentException {
    throw new UnsupportedOperationException();
  }

  // latest AEM Cloud API
  @Override
  public @NotNull Calendar getCreated() {
    throw new UnsupportedOperationException();
  }

  @Override
  public VersionDef createVersion(String label, String comment) throws ContentFragmentException {
    throw new UnsupportedOperationException();
  }

  @Override
  public VersionedContent getVersionedContent(VersionDef version) throws ContentFragmentException {
    throw new UnsupportedOperationException();
  }

  @Override
  public Iterator<VersionDef> listVersions() throws ContentFragmentException {
    throw new UnsupportedOperationException();
  }

  // latest AEM Cloud API
  @SuppressWarnings("unused")
  public ContentVariation getVersion(VersionDef versionDef) throws ContentFragmentException {
    throw new UnsupportedOperationException();
  }

}
File Project Line
io/wcm/testing/mock/aem/MockContentFragment_ContentElement_Structured.java AEM Mocks Core 125
io/wcm/testing/mock/aem/MockContentFragment_ContentElement_Text.java AEM Mocks Core 142
getVariationStrucuturedDataProps(template.getName()));
  }

  @Override
  public ContentVariation getVariation(String variationName) {
    return getVariationsStream()
        .filter(variation -> StringUtils.equals(variation.getName(), variationName))
        .findFirst().orElse(null);
  }

  @Override
  public Iterator<ContentVariation> getVariations() {
    return getVariationsStream().iterator();
  }

  private Stream<ContentVariation> getVariationsStream() {
    return StreamSupport.stream(
        Spliterators.spliteratorUnknownSize(contentFragment.listAllVariations(), Spliterator.ORDERED), false)
        .map(def -> (ContentVariation)new MockContentFragment_ContentVariation_Structured(def, structuredDataKey,
File Project Line
io/wcm/testing/mock/aem/MockAemAdapterFactory.java AEM Mocks Core 79
io/wcm/testing/mock/aem/dam/MockAemDamAdapterFactory.java AEM Mocks Core 63
@Override
  public @Nullable <AdapterType> AdapterType getAdapter(final @NotNull Object adaptable, final @NotNull Class<AdapterType> type) {
    if (adaptable instanceof Resource) {
      return getAdapter((Resource)adaptable, type);
    }
    if (adaptable instanceof ResourceResolver) {
      return getAdapter((ResourceResolver)adaptable, type);
    }
    return null;
  }

  @SuppressWarnings("unchecked")
  private @Nullable <AdapterType> AdapterType getAdapter(@NotNull final Resource resource, @NotNull final Class<AdapterType> type) {
    if (type == Page.class && isPrimaryType(resource, NT_PAGE)) {

Back to top

Version: 5.5.3-SNAPSHOT. Last Published: 2024-04-23.