Search in sources :

Example 11 with Condition

use of org.assertj.core.api.Condition in project kie-wb-common by kiegroup.

the class DecisionServiceSVGShapeViewTest method testShapeControlResizeHandles.

@Test
public void testShapeControlResizeHandles() {
    final IControlHandleFactory controlHandleFactory = view.getPath().getControlHandleFactory();
    final IControlHandleList controlHandles = controlHandleFactory.getControlHandles(Collections.singletonList(RESIZE)).get(RESIZE);
    assertThat(controlHandles.size()).isGreaterThan(0);
    assertThat(controlHandles).areExactly(1, new Condition<>(ch -> ch instanceof MoveDividerControlHandle, "Is a MoveDividerControlHandle"));
}
Also used : NodeDragStartEvent(com.ait.lienzo.client.core.event.NodeDragStartEvent) WiresResizeStepEvent(com.ait.lienzo.client.core.shape.wires.event.WiresResizeStepEvent) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) MoveDividerControlHandle(org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerControlHandle) NodeDragEndEvent(com.ait.lienzo.client.core.event.NodeDragEndEvent) Mock(org.mockito.Mock) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RunWith(org.junit.runner.RunWith) Shape(com.ait.lienzo.client.core.shape.Shape) Attribute(com.ait.lienzo.client.core.Attribute) DragEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.DragEvent) DragBounds(com.ait.lienzo.client.core.types.DragBounds) SVGPrimitiveShape(org.kie.workbench.common.stunner.svg.client.shape.view.SVGPrimitiveShape) Attributes(com.ait.lienzo.client.core.shape.Attributes) LienzoMockitoTestRunner(com.ait.lienzo.test.LienzoMockitoTestRunner) NodeDragMoveEvent(com.ait.lienzo.client.core.event.NodeDragMoveEvent) DragHandler(org.kie.workbench.common.stunner.core.client.shape.view.event.DragHandler) IControlHandleList(com.ait.lienzo.client.core.shape.wires.IControlHandleList) HandlerManager(com.google.gwt.event.shared.HandlerManager) StreamSupport(java.util.stream.StreamSupport) RESIZE(com.ait.lienzo.client.core.shape.wires.IControlHandle.ControlHandleStandardType.RESIZE) Node(com.ait.lienzo.client.core.shape.Node) Before(org.junit.Before) MoveDividerDragHandler(org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerDragHandler) IControlHandleFactory(com.ait.lienzo.client.core.shape.wires.IControlHandleFactory) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) DragContext(com.ait.lienzo.client.widget.DragContext) IPrimitive(com.ait.lienzo.client.core.shape.IPrimitive) GeneralRectangleDimensionsSet(org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet) Condition(org.assertj.core.api.Condition) Collections(java.util.Collections) MoveDividerControlHandle(org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerControlHandle) IControlHandleList(com.ait.lienzo.client.core.shape.wires.IControlHandleList) IControlHandleFactory(com.ait.lienzo.client.core.shape.wires.IControlHandleFactory) Test(org.junit.Test)

Example 12 with Condition

use of org.assertj.core.api.Condition in project kie-wb-common by kiegroup.

the class DecisionServiceSVGShapeViewTest method testShapeControlResizeHandlersWithList.

@Test
public void testShapeControlResizeHandlersWithList() {
    final IControlHandleFactory controlHandleFactory = view.getPath().getControlHandleFactory();
    final IControlHandleList controlHandles = controlHandleFactory.getControlHandles(RESIZE).get(RESIZE);
    assertThat(controlHandles.size()).isGreaterThan(0);
    assertThat(controlHandles).areExactly(1, new Condition<>(ch -> ch instanceof MoveDividerControlHandle, "Is a MoveDividerControlHandle"));
}
Also used : NodeDragStartEvent(com.ait.lienzo.client.core.event.NodeDragStartEvent) WiresResizeStepEvent(com.ait.lienzo.client.core.shape.wires.event.WiresResizeStepEvent) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) MoveDividerControlHandle(org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerControlHandle) NodeDragEndEvent(com.ait.lienzo.client.core.event.NodeDragEndEvent) Mock(org.mockito.Mock) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RunWith(org.junit.runner.RunWith) Shape(com.ait.lienzo.client.core.shape.Shape) Attribute(com.ait.lienzo.client.core.Attribute) DragEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.DragEvent) DragBounds(com.ait.lienzo.client.core.types.DragBounds) SVGPrimitiveShape(org.kie.workbench.common.stunner.svg.client.shape.view.SVGPrimitiveShape) Attributes(com.ait.lienzo.client.core.shape.Attributes) LienzoMockitoTestRunner(com.ait.lienzo.test.LienzoMockitoTestRunner) NodeDragMoveEvent(com.ait.lienzo.client.core.event.NodeDragMoveEvent) DragHandler(org.kie.workbench.common.stunner.core.client.shape.view.event.DragHandler) IControlHandleList(com.ait.lienzo.client.core.shape.wires.IControlHandleList) HandlerManager(com.google.gwt.event.shared.HandlerManager) StreamSupport(java.util.stream.StreamSupport) RESIZE(com.ait.lienzo.client.core.shape.wires.IControlHandle.ControlHandleStandardType.RESIZE) Node(com.ait.lienzo.client.core.shape.Node) Before(org.junit.Before) MoveDividerDragHandler(org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerDragHandler) IControlHandleFactory(com.ait.lienzo.client.core.shape.wires.IControlHandleFactory) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) DragContext(com.ait.lienzo.client.widget.DragContext) IPrimitive(com.ait.lienzo.client.core.shape.IPrimitive) GeneralRectangleDimensionsSet(org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet) Condition(org.assertj.core.api.Condition) Collections(java.util.Collections) MoveDividerControlHandle(org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerControlHandle) IControlHandleList(com.ait.lienzo.client.core.shape.wires.IControlHandleList) IControlHandleFactory(com.ait.lienzo.client.core.shape.wires.IControlHandleFactory) Test(org.junit.Test)

Example 13 with Condition

use of org.assertj.core.api.Condition in project kie-wb-common by kiegroup.

the class FormDefinitionGeneratorWithUnsupportedFieldsTest method testMigration.

@Test
public void testMigration() {
    generator.execute(context);
    Assertions.assertThat(context.getSummaries()).isNotEmpty().hasSize(1);
    Assertions.assertThat(context.getExtraSummaries()).isEmpty();
    // 1 legacyforms + 1 migrated forms
    verify(migrationServicesCDIWrapper, times(2)).write(any(Path.class), anyString(), anyString());
    FormMigrationSummary summary = context.getSummaries().iterator().next();
    Form originalForm = summary.getOriginalForm().get();
    FormDefinition newForm = summary.getNewForm().get();
    assertNotNull(newForm);
    Assertions.assertThat(newForm.getFields()).isNotEmpty().hasSize(1);
    LayoutTemplate newLayout = newForm.getLayoutTemplate();
    assertNotNull(newLayout);
    Assertions.assertThat(newLayout.getRows()).isNotEmpty().hasSize(2);
    // Checking first field (login), althought the original field type isn't supported it can be migrated to a textbox
    Field originalLogin = originalForm.getField(USER_LOGIN);
    FieldDefinition newLogin = newForm.getFieldByName(USER_LOGIN);
    assertNotNull(newLogin);
    checkFieldDefinition(newLogin, USER_LOGIN, "login", "login", TextBoxFieldDefinition.class, newForm, originalLogin);
    LayoutRow loginRow = newLayout.getRows().get(0);
    assertNotNull(loginRow);
    Assertions.assertThat(loginRow.getLayoutColumns()).isNotEmpty().hasSize(1);
    LayoutColumn loginColumn = loginRow.getLayoutColumns().get(0);
    assertNotNull(loginColumn);
    assertEquals("12", loginColumn.getSpan());
    Assertions.assertThat(loginColumn.getLayoutComponents()).isNotEmpty().hasSize(1);
    checkLayoutFormField(loginColumn.getLayoutComponents().get(0), newLogin, newForm);
    // Checking second field (password), the original field type isn't supported and it cannot be migrated to any
    // other form control. There shouldn't be any FieldDefinition for it but it should be an HTML component on
    // the layout warning about the error
    assertNull(newForm.getFieldByName(USER_PASSWORD));
    LayoutRow passwordRow = newLayout.getRows().get(1);
    assertNotNull(passwordRow);
    Assertions.assertThat(passwordRow.getLayoutColumns()).isNotEmpty().hasSize(1);
    LayoutColumn passwordColumn = passwordRow.getLayoutColumns().get(0);
    assertNotNull(passwordColumn);
    assertEquals("12", passwordColumn.getSpan());
    Assertions.assertThat(passwordColumn.getLayoutComponents()).isNotEmpty().hasSize(1);
    LayoutComponent passwordComponent = passwordColumn.getLayoutComponents().get(0);
    Assertions.assertThat(passwordComponent).isNotNull().hasFieldOrPropertyWithValue("dragTypeName", FormsMigrationConstants.HTML_COMPONENT);
    Field originalPassword = originalForm.getField(USER_PASSWORD);
    Formatter formatter = new Formatter();
    formatter.format(FormsMigrationConstants.UNSUPORTED_FIELD_HTML_TEMPLATE, originalPassword.getFieldName(), originalPassword.getFieldType().getCode());
    final String expectedHtmlMessage = formatter.toString();
    Assertions.assertThat(passwordComponent.getProperties()).hasEntrySatisfying(FormsMigrationConstants.HTML_CODE_PARAMETER, new Condition<>(htmlMessage -> htmlMessage.equals(expectedHtmlMessage), "Invalid error HTML message"));
    formatter.close();
}
Also used : Path(org.uberfire.backend.vfs.Path) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Resource(org.kie.workbench.common.forms.migration.tool.Resource) MigrationContext(org.kie.workbench.common.forms.migration.tool.pipelines.MigrationContext) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) LayoutComponent(org.uberfire.ext.layout.editor.api.editor.LayoutComponent) ArrayList(java.util.ArrayList) Formatter(java.util.Formatter) FormsMigrationConstants(org.kie.workbench.common.forms.migration.tool.util.FormsMigrationConstants) LayoutRow(org.uberfire.ext.layout.editor.api.editor.LayoutRow) Field(org.kie.workbench.common.forms.migration.legacy.model.Field) FormMigrationSummary(org.kie.workbench.common.forms.migration.tool.FormMigrationSummary) Assertions(org.assertj.core.api.Assertions) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) Path(org.uberfire.backend.vfs.Path) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) Assert.assertNotNull(org.junit.Assert.assertNotNull) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) LayoutColumn(org.uberfire.ext.layout.editor.api.editor.LayoutColumn) Form(org.kie.workbench.common.forms.migration.legacy.model.Form) Mockito.verify(org.mockito.Mockito.verify) List(java.util.List) Assert.assertNull(org.junit.Assert.assertNull) LayoutTemplate(org.uberfire.ext.layout.editor.api.editor.LayoutTemplate) Condition(org.assertj.core.api.Condition) RealSystemAccess(org.kie.workbench.common.migration.cli.RealSystemAccess) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Assert.assertEquals(org.junit.Assert.assertEquals) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) LayoutTemplate(org.uberfire.ext.layout.editor.api.editor.LayoutTemplate) Form(org.kie.workbench.common.forms.migration.legacy.model.Form) Formatter(java.util.Formatter) FormMigrationSummary(org.kie.workbench.common.forms.migration.tool.FormMigrationSummary) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) LayoutColumn(org.uberfire.ext.layout.editor.api.editor.LayoutColumn) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Field(org.kie.workbench.common.forms.migration.legacy.model.Field) LayoutRow(org.uberfire.ext.layout.editor.api.editor.LayoutRow) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) LayoutComponent(org.uberfire.ext.layout.editor.api.editor.LayoutComponent) Test(org.junit.Test)

Example 14 with Condition

use of org.assertj.core.api.Condition in project project-build-plugin by axonivy.

the class TestDeployToRunningEngine method canDeployIar.

@Test
public void canDeployIar() throws Exception {
    StartTestEngineMojo mojo = rule.getMojo();
    DeployToEngineMojo deployMojo = deployRule.getMojo();
    deployMojo.deployTimeoutInSeconds = 120;
    deployMojo.deployEngineDirectory = mojo.engineDirectory.getAbsoluteFile();
    deployMojo.deployFile = new File("src/test/resources/deploy-single-7.1.0-SNAPSHOT.iar");
    deployMojo.deployTestUsers = true;
    deployMojo.deployToEngineApplication = "Portal";
    File deployedIar = getTarget(deployMojo.deployFile, deployMojo);
    File deployedIarFlagFile = new File(deployedIar.getParent(), deployedIar.getName() + ".deployed");
    File deployedIarLogFile = new File(deployedIar.getParent(), deployedIar.getName() + ".deploymentLog");
    Executor startedProcess = null;
    try {
        startedProcess = mojo.startEngine();
        deployMojo.execute();
        assertThat(deployedIar).doesNotExist();
        assertThat(deployedIarFlagFile).exists();
        assertThat(deployedIarLogFile).exists();
        assertThat(linesOf(deployedIarLogFile)).haveAtLeast(1, new Condition<>(s -> s.contains("Deploying users ..."), ""));
    } finally {
        kill(startedProcess);
    }
}
Also used : Executor(org.apache.commons.exec.Executor) Rule(org.junit.Rule) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Condition(org.assertj.core.api.Condition) Test(org.junit.Test) Assertions.linesOf(org.assertj.core.api.Assertions.linesOf) File(java.io.File) Executor(org.apache.commons.exec.Executor) File(java.io.File) Test(org.junit.Test)

Example 15 with Condition

use of org.assertj.core.api.Condition in project robozonky by RoboZonky.

the class SessionTest method underBalance.

@Test
void underBalance() {
    final Participation p = mock(Participation.class);
    when(p.getRemainingPrincipal()).thenReturn(BigDecimal.valueOf(200));
    final Loan l = Loan.custom().build();
    final PurchaseStrategy s = mock(PurchaseStrategy.class);
    when(s.recommend(any(), any(), any())).thenAnswer(i -> {
        final Collection<ParticipationDescriptor> participations = i.getArgument(0);
        return participations.stream().map(ParticipationDescriptor::recommend).flatMap(o -> o.map(Stream::of).orElse(Stream.empty()));
    });
    final ParticipationDescriptor pd = new ParticipationDescriptor(p, l);
    final Zonky z = mockZonky();
    final Authenticated auth = mockAuthentication(z);
    final Portfolio portfolio = Portfolio.create(z, mockBalance(z));
    final Collection<Investment> i = Session.purchase(portfolio, auth, Stream.of(pd), new RestrictedPurchaseStrategy(s, new Restrictions()), true);
    assertSoftly(softly -> {
        softly.assertThat(i).isEmpty();
        softly.assertThat(this.getNewEvents()).has(new Condition<List<? extends Event>>() {

            @Override
            public boolean matches(final List<? extends Event> events) {
                return events.stream().noneMatch(e -> e instanceof PurchaseRequestedEvent);
            }
        });
    });
}
Also used : SoftAssertions(org.assertj.core.api.SoftAssertions) Collection(java.util.Collection) Loan(com.github.robozonky.api.remote.entities.sanitized.Loan) PurchaseStrategy(com.github.robozonky.api.strategies.PurchaseStrategy) Wallet(com.github.robozonky.api.remote.entities.Wallet) Zonky(com.github.robozonky.common.remote.Zonky) ParticipationDescriptor(com.github.robozonky.api.strategies.ParticipationDescriptor) Event(com.github.robozonky.api.notifications.Event) Test(org.junit.jupiter.api.Test) BigDecimal(java.math.BigDecimal) Restrictions(com.github.robozonky.api.remote.entities.Restrictions) Mockito(org.mockito.Mockito) List(java.util.List) Stream(java.util.stream.Stream) PurchaseRequestedEvent(com.github.robozonky.api.notifications.PurchaseRequestedEvent) Authenticated(com.github.robozonky.app.authentication.Authenticated) Investment(com.github.robozonky.api.remote.entities.sanitized.Investment) Condition(org.assertj.core.api.Condition) Rating(com.github.robozonky.api.remote.enums.Rating) Assertions(org.assertj.core.api.Assertions) AbstractZonkyLeveragingTest(com.github.robozonky.app.AbstractZonkyLeveragingTest) Portfolio(com.github.robozonky.app.portfolio.Portfolio) Participation(com.github.robozonky.api.remote.entities.Participation) Participation(com.github.robozonky.api.remote.entities.Participation) Authenticated(com.github.robozonky.app.authentication.Authenticated) PurchaseRequestedEvent(com.github.robozonky.api.notifications.PurchaseRequestedEvent) Portfolio(com.github.robozonky.app.portfolio.Portfolio) Zonky(com.github.robozonky.common.remote.Zonky) PurchaseStrategy(com.github.robozonky.api.strategies.PurchaseStrategy) Loan(com.github.robozonky.api.remote.entities.sanitized.Loan) Event(com.github.robozonky.api.notifications.Event) PurchaseRequestedEvent(com.github.robozonky.api.notifications.PurchaseRequestedEvent) ParticipationDescriptor(com.github.robozonky.api.strategies.ParticipationDescriptor) Stream(java.util.stream.Stream) List(java.util.List) Restrictions(com.github.robozonky.api.remote.entities.Restrictions) Investment(com.github.robozonky.api.remote.entities.sanitized.Investment) Test(org.junit.jupiter.api.Test) AbstractZonkyLeveragingTest(com.github.robozonky.app.AbstractZonkyLeveragingTest)

Aggregations

Condition (org.assertj.core.api.Condition)33 Test (org.junit.Test)19 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)16 List (java.util.List)9 Before (org.junit.Before)7 File (java.io.File)5 IOException (java.io.IOException)5 Arrays (java.util.Arrays)5 ExecutorService (java.util.concurrent.ExecutorService)4 Assertions (org.assertj.core.api.Assertions)4 Rule (org.junit.Rule)4 Mock (org.mockito.Mock)4 When (io.cucumber.java.en.When)3 SupportPage (io.syndesis.qe.pages.SupportPage)3 InetAddress (java.net.InetAddress)3 ArrayList (java.util.ArrayList)3 Collections (java.util.Collections)3 Enumeration (java.util.Enumeration)3 TimeUnit (java.util.concurrent.TimeUnit)3 ZipEntry (java.util.zip.ZipEntry)3