Skip to content

Commit

Permalink
Fix a few minor config warnings in iaf-test (#8152)
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsm5 authored Dec 25, 2024
1 parent 082a644 commit 6ffb4f3
Show file tree
Hide file tree
Showing 11 changed files with 712 additions and 442 deletions.
20 changes: 9 additions & 11 deletions core/src/main/java/org/frankframework/pipes/ForPipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class ForPipe extends AbstractPipe {

static final String STOP_FORWARD_NAME = "stop";
static final String CONTINUE_FORWARD_NAME = "continue";
static final String STOP_AT_PARAMETER_VALUE = "stopAt";
static final String STOP_AT_PARAMETER_NAME = "stopAt";
private static final String INCREMENT_SESSION_KEY_SUFFIX = "iteration";
private @Getter int startAt = 0;
private @Getter Integer stopAt = null;
Expand All @@ -71,12 +71,12 @@ public void configure() throws ConfigurationException {
super.configure();

// Mandatory stopAt attribute / parameter
if (stopAt == null && !getParameterList().hasParameter(STOP_AT_PARAMETER_VALUE)) {
throw new ConfigurationException("Value for 'stopAt' is mandatory to break out of the for loop pipe");
if (stopAt == null && !getParameterList().hasParameter(STOP_AT_PARAMETER_NAME)) {
throw new ConfigurationException("value for 'stopAt' is mandatory to break out of the for loop pipe");
}

if (stopAt != null && getParameterList().hasParameter(STOP_AT_PARAMETER_VALUE)) {
ConfigurationWarnings.add(this, log, "Value for 'stopAt' is set both as attribute and Parameter, please use one of the two options");
if (stopAt != null && getParameterList().hasParameter(STOP_AT_PARAMETER_NAME)) {
ConfigurationWarnings.add(this, log, "value for 'stopAt' is set both as attribute and Parameter, please use one of the two options");
}

// Mandatory forwards
Expand Down Expand Up @@ -122,15 +122,15 @@ private Integer determineStopAtValue(Message message, PipeLineSession session) t
return getParameterValueList(message, session)
.map(this::getIntegerValue)
.or(() -> Optional.ofNullable(stopAt))
.orElseThrow(() -> new PipeRunException(this, "Can't determine 'stopAt' value"));
.orElseThrow(() -> new PipeRunException(this, "can't determine 'stopAt' value"));

}

private Integer getIntegerValue(ParameterValueList list) {
int defaultValue = (stopAt != null) ? stopAt : 0;

if (list.contains(STOP_AT_PARAMETER_VALUE) && !list.get(STOP_AT_PARAMETER_VALUE).asStringValue().isBlank()) {
return list.get(STOP_AT_PARAMETER_VALUE).asIntegerValue(defaultValue);
if (list.contains(STOP_AT_PARAMETER_NAME) && !list.get(STOP_AT_PARAMETER_NAME).asStringValue().isBlank()) {
return list.get(STOP_AT_PARAMETER_NAME).asIntegerValue(defaultValue);
}

return null;
Expand Down Expand Up @@ -158,9 +158,7 @@ public void setStartAt(int startAt) {
}

/**
* Break from the loop when incrementSessionKey equals this value
*
* @ff.mandatory
* Break from the loop when incrementSessionKey equals this value.
*/
public void setStopAt(Integer stopAt) {
this.stopAt = stopAt;
Expand Down
432 changes: 292 additions & 140 deletions core/src/main/resources/xml/xsd/FrankConfig-compatibility.xsd

Large diffs are not rendered by default.

631 changes: 375 additions & 256 deletions core/src/main/resources/xml/xsd/FrankConfig.xsd

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions core/src/test/java/org/frankframework/pipes/ForPipeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void assertForwardsSet() throws ConfigurationException {

@Test
void assertFailOnDoubleStopAt() throws ConfigurationException {
pipe.addParameter(NumberParameterBuilder.create().withName(ForPipe.STOP_AT_PARAMETER_VALUE).withValue(10));
pipe.addParameter(NumberParameterBuilder.create().withName(ForPipe.STOP_AT_PARAMETER_NAME).withValue(10));
pipe.setStopAt(10);

pipe.addForward(new PipeForward("continue", null));
Expand Down Expand Up @@ -94,7 +94,7 @@ void testIncrement(boolean useParameter) throws PipeRunException, IOException, C
String dummyInput = "dummyInput";

if (useParameter) {
pipe.addParameter(NumberParameterBuilder.create().withName(ForPipe.STOP_AT_PARAMETER_VALUE).withValue(10));
pipe.addParameter(NumberParameterBuilder.create().withName(ForPipe.STOP_AT_PARAMETER_NAME).withValue(10));
} else {
pipe.setStopAt(10);
}
Expand Down Expand Up @@ -122,7 +122,7 @@ void testIncrement(boolean useParameter) throws PipeRunException, IOException, C
void testFailOnEmptyParameter() throws Exception {
String dummyInput = "dummyInput";

pipe.addParameter(new Parameter(ForPipe.STOP_AT_PARAMETER_VALUE, ""));
pipe.addParameter(new Parameter(ForPipe.STOP_AT_PARAMETER_NAME, ""));
pipe.addForward(new PipeForward("continue", null));
pipe.addForward(new PipeForward("stop", null));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class ExchangeFileSystemActorTest extends FileSystemActorTest<MailItemId,
private static String tenantId;

// Should ideally never be `inbox` as it removes all mail items!
private String baseFolder = properties.getProperty("baseFolder", "Inbox/iafTest");
private String baseFolder = properties.getProperty("baseFolder", ExchangeFileSystemTestHelper.DEFAULT_BASE_FOLDER);

@BeforeAll
public static void beforeAll() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class ExchangeFileSystemListenerTest extends BasicFileSystemListenerTest<
private static String tenantId;

// Should ideally never be `inbox` as it removes all mail items!
private String baseFolder = properties.getProperty("baseFolder", "Inbox/iafTest");
private String baseFolder = properties.getProperty("baseFolder", ExchangeFileSystemTestHelper.DEFAULT_BASE_FOLDER);

@BeforeAll
public static void beforeAll() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class ExchangeFileSystemSenderTest extends FileSystemSenderTest<ExchangeF
private static String tenantId;

// Should ideally never be `inbox` as it removes all mail items!
private String baseFolder = properties.getProperty("baseFolder", "Inbox/iafTest");
private String baseFolder = properties.getProperty("baseFolder", ExchangeFileSystemTestHelper.DEFAULT_BASE_FOLDER);

@BeforeAll
public static void beforeAll() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class ExchangeFileSystemTest extends HelperedBasicFileSystemTest<MailItem
private static String tenantId;

// Should ideally never be `inbox` as it removes all mail items!
private String baseFolder = properties.getProperty("baseFolder", "Inbox/iafTest");
private String baseFolder = properties.getProperty("baseFolder", ExchangeFileSystemTestHelper.DEFAULT_BASE_FOLDER);

@BeforeAll
public static void beforeAll() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,15 @@
@Log4j2
public class ExchangeFileSystemTestHelper implements IFileSystemTestHelper {
public static final int WAIT_MILLIS = 250;
public static final String DEFAULT_BASE_FOLDER = "Inbox/iaf-test";

private static final String SCOPE = "https://graph.microsoft.com/.default";

private String clientId;
private String clientSecret;
private String authAlias;
private String tenantId;
private String mailAddress;
private String baseFolder;
private boolean createBaseFolder = true;
private final String clientId;
private final String clientSecret;
private final String tenantId;
private final String mailAddress;
private final String baseFolder;

private String baseFolderId;
private MailFolderItemRequestBuilder baseMailFolder;
Expand All @@ -64,7 +63,7 @@ public ExchangeFileSystemTestHelper(String clientId, String clientSecret, String
@Override
public void setUp() throws Exception {
if (userId == null) {
CredentialFactory cf = new CredentialFactory(authAlias, clientId, clientSecret);
CredentialFactory cf = new CredentialFactory(null, clientId, clientSecret);
TokenCredential credential = new ClientSecretCredentialBuilder()
.tenantId(tenantId)
.clientId(cf.getUsername())
Expand Down Expand Up @@ -97,27 +96,34 @@ public void setUp() throws Exception {
}
}
if (!found) {
if (createBaseFolder) {
MailFolder mailFolder = new MailFolder();
mailFolder.setDisplayName(subMailFolder);
mailFolder.setIsHidden(false);
base = requestBuilder.mailFolders().byMailFolderId(base.getId()).childFolders().post(mailFolder);
log.debug("created mail folder [{}] with id [{}]", subMailFolder, base.getId());
} else {
throw new IllegalStateException("cannot find mailfolder ["+subMailFolder+"] in mailbox ");
}
MailFolder mailFolder = new MailFolder();
mailFolder.setDisplayName(subMailFolder);
mailFolder.setIsHidden(false);
base = requestBuilder.mailFolders().byMailFolderId(base.getId()).childFolders().post(mailFolder);
log.debug("created mail folder [{}] with id [{}]", subMailFolder, base.getId());
}
}

log.debug("using MailFolder id [{}]", base.getId());
baseFolderId = base.getId();
baseMailFolder = requestBuilder.mailFolders().byMailFolderId(baseFolderId);

cleanMailFolder();
cleanBaseMailFolder();
}
}

private void cleanMailFolder() {
@Override
public void tearDown() {
cleanBaseMailFolder();

// Remove the base directory it self.
if(!"inbox".equalsIgnoreCase(baseMailFolder.get().getDisplayName())) {
deleteFolderById(baseFolderId);
}
}

/** Removes all files and folders in the base directory */
private void cleanBaseMailFolder() {
List<MailFolder> folders = baseMailFolder.childFolders().get().getValue();
for (MailFolder mailFolder : folders) {
deleteFolderById(mailFolder.getId());
Expand Down Expand Up @@ -154,11 +160,6 @@ private MailFolder findFolder(String folderNames) {
return base;
}

@Override
public void tearDown() throws Exception {
// Nothing to do here
}

@Override
public boolean _fileExists(String folder, String filename) throws Exception {
String mailFolderId = baseFolderId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<module>
<Adapter name="ForPipe">
<Receiver name="ForPipe">
<JavaListener serviceName="ibis4test-ForPipe" />
<JavaListener name="ForPipe" serviceName="ibis4test-ForPipe" />
</Receiver>
<Pipeline firstPipe="forPipe">
<Exit path="EXIT" state="success" />

<ForPipe name="forPipe" startAt="0" stopAt="10">
<ForPipe name="forPipe" stopAt="10">
<Forward name="stop" path="EXIT" />
<Forward name="continue" path="echoPipe"/>
</ForPipe>
Expand All @@ -17,7 +17,7 @@
</Adapter>
<Adapter name="ForPipeWithParam">
<Receiver name="ForPipe">
<JavaListener serviceName="ibis4test-ForPipeWithParam" />
<JavaListener name="ForPipeWithParam" serviceName="ibis4test-ForPipeWithParam" />
</Receiver>
<Pipeline firstPipe="forPipe">
<Exit path="EXIT" state="success" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<module>
<Adapter name="RegExPipe">
<Receiver name="RegExPipe">
<JavaListener serviceName="ibis4test-RegExPipe" />
<JavaListener name="RegExPipe" serviceName="ibis4test-RegExPipe" />
</Receiver>
<Pipeline firstPipe="regExPipe">
<Exit path="EXIT" state="success" />
Expand Down

0 comments on commit 6ffb4f3

Please sign in to comment.