Skip to content

Commit

Permalink
More unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cuioss committed Jul 29, 2023
1 parent c6ce74a commit bf8d0ca
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package de.cuioss.portal.ui.api;

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

import org.junit.jupiter.api.Test;

/**
* Quite nonsense, coverage only
*/
class GlobalComponentIdsTest {

@Test
void eachShouldProvideIdentifier() {
for (GlobalComponentIds ids : GlobalComponentIds.values()) {
assertNotNull(ids.getId());
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import lombok.Getter;

@EnableAutoWeld
@AddBeanClasses({ SupportProducer.class })
@AddBeanClasses({ LazyLoadingTestSupportProducer.class })
class BaseLazyLoadingWidgetTest
implements ShouldBeNotNull<TestLazyLoadingWidget>, ShouldImplementEqualsAndHashCode<TestLazyLoadingWidget> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import de.cuioss.uimodel.result.ResultObject;

@ApplicationScoped
class SupportProducer {
public class LazyLoadingTestSupportProducer {

@Produces
@Dependent
Expand All @@ -24,7 +24,7 @@ class SupportProducer {
@Dependent
private LazyLoadingThreadModel<String> threadModell;

public SupportProducer() {
public LazyLoadingTestSupportProducer() {
viewController = request -> {
// TODO Auto-generated method stub

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package de.cuioss.portal.ui.api.exceptions;

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

import org.junit.jupiter.api.Test;

import de.cuioss.portal.core.storage.impl.MapStorageImpl;
import de.cuioss.test.valueobjects.ValueObjectTest;
import de.cuioss.test.valueobjects.api.contracts.VerifyConstructor;

@VerifyConstructor(of = { "errorCode", "errorTicket", "errorMessage", "pageId" })
class DefaultErrorMessageTest extends ValueObjectTest<DefaultErrorMessage> {

@Test
void shouldAddToMap() {
var message = anyValueObject();
var storage = new MapStorageImpl<>();
DefaultErrorMessage.addErrorMessageToSessionStorage(message, storage);
assertEquals(message, storage.get(DefaultErrorMessage.LOOKUP_KEY));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package de.cuioss.portal.ui.api.ui;

import de.cuioss.test.valueobjects.junit5.contracts.ShouldBeNotNull;

class Jsf23EnablerBeanTest implements ShouldBeNotNull<Jsf23EnablerBean> {

@Override
public Jsf23EnablerBean getUnderTest() {
return new Jsf23EnablerBean();
}

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

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

import javax.inject.Inject;

import org.jboss.weld.junit5.auto.AddBeanClasses;
import org.jboss.weld.junit5.auto.EnableAutoWeld;
import org.junit.jupiter.api.Test;

import de.cuioss.jsf.api.common.view.ViewDescriptor;
import de.cuioss.test.jsf.junit5.EnableJsfEnvironment;
import de.cuioss.test.valueobjects.junit5.contracts.ShouldBeNotNull;
import lombok.Getter;

@EnableJsfEnvironment
@EnableAutoWeld
@AddBeanClasses({ CurrentViewProducer.class })
class CurrentViewProducerTest implements ShouldBeNotNull<ViewDescriptor> {

@Inject
@CuiCurrentView
@Getter
private ViewDescriptor underTest;

@Inject
private CurrentViewProducer producer;

@Test
void shouldHandleCurrentView() {
assertNotNull(producer.getCurrentView());
}

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

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

import javax.inject.Inject;

import org.jboss.weld.junit5.auto.AddBeanClasses;
import org.jboss.weld.junit5.auto.EnableAutoWeld;
import org.junit.jupiter.api.Test;

@EnableAutoWeld
@AddBeanClasses({ CurrentViewProducer.class })
class CurrentViewProducerTestWOFacesContextTest {

@Inject
private CurrentViewProducer producer;

@Test
void shouldHandleCurrentView() {
assertNotNull(producer.getCurrentView());
}

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

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;

import javax.inject.Inject;

import org.jboss.weld.junit5.auto.AddBeanClasses;
import org.jboss.weld.junit5.auto.EnableAutoWeld;
import org.junit.jupiter.api.Test;

import de.cuioss.portal.ui.api.dashboard.LazyLoadingTestSupportProducer;
import de.cuioss.test.valueobjects.junit5.contracts.ShouldBeNotNull;
import de.cuioss.test.valueobjects.junit5.contracts.ShouldImplementEqualsAndHashCode;
import lombok.Getter;

@EnableAutoWeld
@AddBeanClasses({ LazyLoadingTestSupportProducer.class, TestBaseLazyLoadingRequest.class })
class BaseLazyLoadingRequestTest implements ShouldBeNotNull<TestBaseLazyLoadingRequest>,
ShouldImplementEqualsAndHashCode<TestBaseLazyLoadingRequest> {

@Inject
@Getter
private TestBaseLazyLoadingRequest underTest;

@Test
void shouldDelegateHappyCase() {

assertDoesNotThrow(() -> underTest.getRequestId());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package de.cuioss.portal.ui.api.ui.lazyloading;

import de.cuioss.uimodel.result.ResultObject;

public class TestBaseLazyLoadingRequest extends BaseLazyLoadingRequest<String> {

@Override
public ResultObject<String> backendRequest() {
return null;
}

@Override
public void handleResult(String result) {

}

}

0 comments on commit bf8d0ca

Please sign in to comment.