Skip to content

Commit

Permalink
Removing PortalApplicationProducer, adding unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cuioss committed Jul 29, 2023
1 parent a96aa72 commit b7e34ae
Show file tree
Hide file tree
Showing 14 changed files with 150 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
- name: Deploy Snapshot with Maven, version ${{ steps.project.outputs.version }}
if: ${{endsWith(steps.project.outputs.version, '-SNAPSHOT')}}
run: |
mvn -B -Prelease-snapshot javadoc:javadoc
mvn -B -Prelease-snapshot javadoc:javadoc install
mvn -B -Prelease-snapshot deploy -Dmaven.test.skip=true
env:
MAVEN_USERNAME: ${{ secrets.OSS_SONATYPE_USERNAME }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

/**
* Utilized for statically extending the default {@link MultiViewMapper} defined
* by cui-portal-core-cdi-impl. Provides information which views are to be
* handled by which concrete faces-Directory, see package-info for details.
* by portal-ui-api. Provides information which views are to be handled by which
* concrete faces-Directory, see package-info for details.
*
* @author Oliver Wolff
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* Provides theming related identifier. See
* com.icw.ehf.cui.core.api.application.theme on how theming works within cui
* Provides theming related identifier.
*
* @author Oliver Wolff
*/
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package de.cuioss.portal.ui.api.menu.items;

import javax.inject.Inject;
import javax.inject.Provider;

import org.jboss.weld.junit5.auto.AddBeanClasses;
import org.jboss.weld.junit5.auto.EnableAutoWeld;

import de.cuioss.portal.core.test.junit5.EnablePortalConfiguration;
import de.cuioss.portal.ui.api.menu.PortalMenuItem;
import de.cuioss.test.valueobjects.junit5.contracts.ShouldHandleObjectContracts;

@EnableAutoWeld
@AddBeanClasses(AboutMenuItem.class)
@EnablePortalConfiguration
class AboutMenuItemTest implements ShouldHandleObjectContracts<AboutMenuItem> {

@Inject
@PortalMenuItem
private Provider<AboutMenuItem> underTestProvider;

@Override
public AboutMenuItem getUnderTest() {
return underTestProvider.get();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package de.cuioss.portal.ui.api.menu.items;

import javax.inject.Inject;
import javax.inject.Provider;

import org.jboss.weld.junit5.auto.AddBeanClasses;
import org.jboss.weld.junit5.auto.EnableAutoWeld;

import de.cuioss.portal.core.test.junit5.EnablePortalConfiguration;
import de.cuioss.portal.ui.api.menu.PortalMenuItem;
import de.cuioss.test.valueobjects.junit5.contracts.ShouldHandleObjectContracts;

@EnableAutoWeld
@AddBeanClasses(AccountMenuItem.class)
@EnablePortalConfiguration
class AcountMenuItemTest implements ShouldHandleObjectContracts<AccountMenuItem> {

@Inject
@PortalMenuItem
private Provider<AccountMenuItem> underTestProvider;

@Override
public AccountMenuItem getUnderTest() {
return underTestProvider.get();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package de.cuioss.portal.ui.api.menu.items;

import javax.inject.Inject;
import javax.inject.Provider;

import org.jboss.weld.junit5.auto.AddBeanClasses;
import org.jboss.weld.junit5.auto.EnableAutoWeld;

import de.cuioss.portal.core.test.junit5.EnablePortalConfiguration;
import de.cuioss.portal.ui.api.menu.PortalMenuItem;
import de.cuioss.test.valueobjects.junit5.contracts.ShouldHandleObjectContracts;

@EnableAutoWeld
@AddBeanClasses(LogoutMenuItem.class)
@EnablePortalConfiguration
class LogoutMenuItemTest implements ShouldHandleObjectContracts<LogoutMenuItem> {

@Inject
@PortalMenuItem
private Provider<LogoutMenuItem> underTestProvider;

@Override
public LogoutMenuItem getUnderTest() {
return underTestProvider.get();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package de.cuioss.portal.ui.api.menu.items;

import javax.inject.Inject;
import javax.inject.Provider;

import org.jboss.weld.junit5.auto.AddBeanClasses;
import org.jboss.weld.junit5.auto.EnableAutoWeld;

import de.cuioss.portal.core.test.junit5.EnablePortalConfiguration;
import de.cuioss.portal.ui.api.menu.PortalMenuItem;
import de.cuioss.test.valueobjects.junit5.contracts.ShouldHandleObjectContracts;

@EnableAutoWeld
@AddBeanClasses(PreferencesMenuItem.class)
@EnablePortalConfiguration
class PreferencesMenuItemTest implements ShouldHandleObjectContracts<PreferencesMenuItem> {

@Inject
@PortalMenuItem
private Provider<PreferencesMenuItem> underTestProvider;

@Override
public PreferencesMenuItem getUnderTest() {
return underTestProvider.get();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package de.cuioss.portal.ui.api.menu.items;

import javax.inject.Inject;
import javax.inject.Provider;

import org.jboss.weld.junit5.auto.AddBeanClasses;
import org.jboss.weld.junit5.auto.EnableAutoWeld;

import de.cuioss.portal.core.test.junit5.EnablePortalConfiguration;
import de.cuioss.portal.core.test.mocks.authentication.PortalTestUserProducer;
import de.cuioss.portal.ui.api.menu.PortalMenuItem;
import de.cuioss.portal.ui.api.test.support.PortalResourceBundleMock;
import de.cuioss.test.valueobjects.junit5.contracts.ShouldHandleObjectContracts;

@EnableAutoWeld
@AddBeanClasses({ UserMenuItem.class, PortalTestUserProducer.class, PortalResourceBundleMock.class })
@EnablePortalConfiguration
class UserMenuItemTest implements ShouldHandleObjectContracts<UserMenuItem> {

@Inject
@PortalMenuItem
private Provider<UserMenuItem> underTestProvider;

@Override
public UserMenuItem getUnderTest() {
return underTestProvider.get();
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package de.cuioss.portal.ui.runtime.application.factory;
package de.cuioss.portal.ui.runtime.application;

import javax.faces.application.Application;
import javax.faces.application.ApplicationFactory;
import javax.faces.application.ApplicationWrapper;

import de.cuioss.portal.ui.runtime.application.PortalApplication;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

Expand All @@ -18,7 +17,7 @@ public class PortalApplicationFactory extends ApplicationFactory {

@Getter
private final ApplicationFactory wrapped;
private volatile Application application;
private Application application;

/**
* Returns an instance of {@link PortalApplication} which wraps the original
Expand Down Expand Up @@ -49,7 +48,7 @@ public void setApplication(final Application application) {
private Application createPortalApplication(final Application application) {
synchronized (PortalApplicationFactory.class) {
var toBeWrapped = application;
while (!(toBeWrapped instanceof PortalApplication) && toBeWrapped instanceof ApplicationWrapper) {
while (!(toBeWrapped instanceof PortalApplication) && (toBeWrapped instanceof ApplicationWrapper)) {
toBeWrapped = ((ApplicationWrapper) toBeWrapped).getWrapped();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<message-bundle>de.cuioss.portal.ui.i18n.jsf_messages</message-bundle>
</application>
<factory>
<application-factory>de.cuioss.portal.ui.runtime.application.factory.PortalApplicationFactory</application-factory>
<application-factory>de.cuioss.portal.ui.runtime.application.PortalApplicationFactory</application-factory>
</factory>

<converter>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package de.cuioss.portal.ui.runtime.application.factory;
package de.cuioss.portal.ui.runtime.application;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import javax.faces.FactoryFinder;
import javax.faces.application.ApplicationFactory;

import org.junit.jupiter.api.Test;

import de.cuioss.portal.ui.runtime.application.PortalApplication;
import de.cuioss.test.jsf.junit5.EnableJsfEnvironment;
import de.cuioss.test.jsf.util.JsfEnvironmentConsumer;
import de.cuioss.test.jsf.util.JsfEnvironmentHolder;
Expand All @@ -31,7 +30,7 @@ void shouldBuildFromFactoryWithGetMethod() {

var wrapped = factory.getApplication();

assertEquals(PortalApplication.class, wrapped.getClass());
assertInstanceOf(PortalApplication.class, wrapped);
}

@Test
Expand All @@ -44,7 +43,7 @@ void shouldBuildFromFactoryWithSetMethod() {

var wrapped = factory.getApplication();

assertEquals(PortalApplication.class, wrapped.getClass());
assertInstanceOf(PortalApplication.class, wrapped);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import de.cuioss.portal.configuration.impl.producer.PortalProjectStageImpl;
import de.cuioss.portal.core.test.mocks.configuration.PortalTestConfiguration;
import de.cuioss.portal.ui.runtime.application.configuration.LocaleConfiguration;
import de.cuioss.portal.ui.runtime.application.factory.PortalApplicationFactory;
import de.cuioss.portal.ui.runtime.support.EnablePortalCoreEnvironment;
import de.cuioss.test.jsf.util.JsfEnvironmentConsumer;
import de.cuioss.test.jsf.util.JsfEnvironmentHolder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import de.cuioss.jsf.test.mock.application.MirrorCuiRessourcBundle;
import de.cuioss.portal.configuration.impl.producer.PortalProjectStageImpl;
import de.cuioss.portal.core.test.junit5.EnablePortalConfiguration;
import de.cuioss.portal.ui.api.ui.context.ApplicationProducer;
import de.cuioss.portal.ui.api.ui.context.CurrentViewProducer;
import de.cuioss.portal.ui.api.ui.context.NavigationHandlerProducer;
import de.cuioss.portal.ui.test.configuration.PortalNavigationConfiguration;
Expand Down Expand Up @@ -74,7 +73,7 @@
PortalNavigationConfiguration.class })
@AddBeanClasses({ PortalProjectStageImpl.class, PortalMirrorResourceBundle.class, PortalLocaleProducerMock.class,
PortalStickyMessageProducerMock.class, PortalMessageProducerMock.class, JsfObjectsProducers.class,
CurrentViewProducer.class, NavigationHandlerProducer.class, ApplicationProducer.class })
CurrentViewProducer.class, NavigationHandlerProducer.class })
@ActivateScopes({ RequestScoped.class, SessionScoped.class, ConversationScoped.class, ViewScoped.class })
public @interface EnablePortalUiEnvironment {
}

0 comments on commit b7e34ae

Please sign in to comment.