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"));
}
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"));
}
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();
}
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);
}
}
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);
}
});
});
}
Aggregations