ADempiere Business Suite ERP/CRM/MFG/SCM/POS done the Bazaar way in an open and unabated fashion. Focus is on the Community that includes Subject Matter Specialists, Implementors and End-Users.
e-Evolution on develop
Add GH Actions (#32) * Create … Remove travis support and chang… Merge pull request #3327 from e… (compare)
e-Evolution on develop
Minor change fixed error with s… Merge pull request #3326 from e… (compare)
e-Evolution on develop
Fixed error with wrong referenc… Merge pull request #3324 from e… (compare)
@DisplayName("Given the GardenWorld context")
class ProcessBuilderTest extends CommonGWSetup {
private static final String CLIENT_ACCOUNTING_IMMEDIATE = "I";
ProcessBuilder clientAcctProcessor;
ProcessBuilder resetAccounting;
@BeforeEach
void givenClientAccountingEnabled() {
enableClientAccounting();
}
@Nested
@DisplayName("When the first process is created")
class WhenASingleProcessIsCreated {
@BeforeEach
void whenClientAcctProcessorIsCreated() {
clientAcctProcessor = ProcessBuilder.create(ctx)
.process(org.adempiere.process.ClientAcctProcessor.class)
.withTitle("ClientAcctProcessorTest");
}
@Test
@DisplayName("When the first process is run, "
+ "then the process succeeds")
void whenTheClientAcctProcessorIsRun_itSucceeds() {
ProcessInfo info = clientAcctProcessor.execute(trxName);
assertEquals("OK", info.getSummary());
}
@Nested
@DisplayName("When a second process is created")
class WhenASecondProcessIsCreated {
@BeforeEach
void whenFactResetProcessorIsCreated() {
resetAccounting = ProcessBuilder.create(ctx)
.process(org.compiere.process.FactAcctReset.class)
.withTitle("FactAcctReset")
.withParameter(FactAcctReset.AD_CLIENT_ID,
AD_CLIENT_ID)
.withParameter(FactAcctReset.DELETEPOSTING, true)
.withParameter(FactAcctReset.DATEACCT,
TimeUtil.getDay(1999, 01, 01), today);
}
@Test
@DisplayName("When the second process is executed, "
+ "then it succeeds")
void whenTheFactResetProcessorIsRun_itSucceeds() {
ProcessInfo info = resetAccounting.execute(trxName);
assertTrue(info.getSummary().startsWith("Updated"));
}
@Test
@DisplayName("When the first process is executed again, "
+ "then it should succeed")
void butWhenTheClientAcctProcessorIsRun_itShouldSucceed() {
ProcessInfo info = clientAcctProcessor.execute(trxName); // This throws a NPE
assertEquals("OK", info.getSummary());
}
}
}
private void enableClientAccounting() {
MSysConfig gwAccounting = getOrCreateClientAcctConfig();
gwAccounting.setValue(CLIENT_ACCOUNTING_IMMEDIATE);
gwAccounting.saveEx();
}
private MSysConfig getOrCreateClientAcctConfig() {
return clientAccountingConfigs(AD_CLIENT_ID)
.filter(config -> config.getAD_Client_ID() == AD_CLIENT_ID)
.findFirst()
.orElseGet(() -> {
MSysConfig config = new MSysConfig(ctx, 0, null);
config.setName("CLIENT_ACCOUNTING");
config.saveEx();
return config;
});
}
private Stream<MSysConfig> clientAccountingConfigs(int clientId) {
String where = "Name=? AND AD_Client_ID IN (0, ?)";
return new Query(ctx, I_AD_SysConfig.Table_Name, where, null)
.setOnlyActiveRecords(true)
.setParameters("CLIENT_ACCOUNTING", clientId)
.setOrderBy("AD_Client_ID DESC, AD_Org_ID DESC")
.list(MSysConfig.class)
.stream();
}
}
@ProcessRunError@ @Error@ Client Accounting is not enabled
In order to run this process you need to enable client accounting, this can be done in window System Configurator, setting the parameter CLIENT_ACCOUNTING to [I]mmediate or [Q]ueue
+ "throw an exception")
final void whenClientAcctDisabled_throwsException() {
assertThrows(AdempiereException.class, () -> {
process.execute(trxName);
});
}
ProcessInfo info = process.execute(trxName);
if (info.isError())
throw new AdempiereException(info.getThrowable().toString());
private void assertProcessWasSuccessful(ProcessInfo info) {
assertFalse(info.isError());
assertEquals("OK", info.getSummary());
}
@Test
@DisplayName("When passed no parameters, then the process should "
+ "succeed")
final void whenNoParameters_doItReturnsOk() throws Exception {
ProcessInfo info = process.execute(trxName);
assertProcessWasSuccessful(info);
}
Other proiblem that I found was that report to @yamelsenih Yamel , the table FM_Batch have not DateAcct then the return Client Accounting Processor return an NPE for this reason
Here is the fix adempiere/adempiere#3226
@yamelsenih @e-Evolution Travis CI builds don't seem to be running. There may be a credit issue as they move from travis-ci.org to travis-ci.com. It should still be free for Open Source projects. Can you check it out?
Hi @mckayERP thanks, Travis now have plans for free and pay for. I change this to github actions and is ok, here a merge: https://github.com/adempiere/adempiere/runs/1746527315