Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 04:12

    e-Evolution on develop

    Add GH Actions (#32) * Create … Remove travis support and chang… Merge pull request #3327 from e… (compare)

  • 04:12
    e-Evolution closed #3327
  • 02:51
    yamelsenih review_requested #3327
  • 02:51
    yamelsenih labeled #3327
  • 02:51
    yamelsenih assigned #3327
  • 02:51
    yamelsenih review_requested #3327
  • 02:51
    yamelsenih opened #3327
  • 02:51
    yamelsenih milestoned #3327
  • Jan 21 08:51
    mxinyi starred adempiere/adempiere
  • Jan 21 04:18
    jctmf starred adempiere/adempiere
  • Jan 21 03:03
  • Jan 20 05:05

    e-Evolution on develop

    Minor change fixed error with s… Merge pull request #3326 from e… (compare)

  • Jan 20 05:05
    e-Evolution closed #3326
  • Jan 20 03:38
    yamelsenih review_requested #3326
  • Jan 20 03:38
    yamelsenih labeled #3326
  • Jan 20 03:38
    yamelsenih assigned #3326
  • Jan 20 03:38
    yamelsenih milestoned #3326
  • Jan 20 03:38
    yamelsenih opened #3326
  • Jan 20 02:07

    e-Evolution on develop

    Fixed error with wrong referenc… Merge pull request #3324 from e… (compare)

Michael McKay
@mckayERP
@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();

    }

}
Michael McKay
@mckayERP
The last test throws an unexpected NPE. When I trace that cause, I see the processBuilder field is pointing at the FactAcctReset but the processInfo is for the ClientAcctProcessor.
image.png
I think the cause is that the processBuilder field is static.
e-Evolution
@e-Evolution
@mckayERP , can please adding this testing with your branch the refactory for testing
then I can test and same time make merge the refactory testing , please can syncronice your branch with last develop branch
Michael McKay
@mckayERP
@e-Evolution Its been added. Thanks for reviewing this.
e-Evolution
@e-Evolution
@mckayERP , I testing you code and found some problems:
1 reply
or
no return a null value , the first that I executed I got null , I not understand m this throw an exception NPE
I rebuild all project and when a got a value timestamp then the testing continue
e-Evolution
@e-Evolution
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
1 reply
I adding the DateAcct column the FM_Batch only to solve the error
then the testing continue
So the test now show next:
image.png
e-Evolution
@e-Evolution
about the When Acccounting is reset for some case got an exeption :
image.png

@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

5 replies
So that I think that test no have right design, because the Client Accounting is not enabled
e-Evolution
@e-Evolution
I think that the exception is not propagate or thi test is not right
@Test
@DisplayName("Then the ClientAcctProcessor doIt method should "
            + "throw an exception")
    final void whenClientAcctDisabled_throwsException() {

        assertThrows(AdempiereException.class, () -> {
            process.execute(trxName);
        });

    }
because I got exception but the assertThrows not passed
image.png
1 reply
I think your other type y problems are not in the thread to see with processBuilder
I think it is good to always validate that the process is carried out with no exception in all its problems so that you can be sure that before you evaluate any assertion that the process is successful
e-Evolution
@e-Evolution
please adding this lines in your test code when finish any process execution
1 reply
       ProcessInfo info = process.execute(trxName);
            if (info.isError())
                throw new AdempiereException(info.getThrowable().toString());
Michael McKay
@mckayERP
image.png
Michael McKay
@mckayERP
@e-Evolution I responded in threads except for the picture above. I'm not sure if it applied to the comment "I think that the exception is not propagate ..." or not. I marked up the picture to show where the failures are coming from. For the assertThrows, no error was caught - which means the exception was thrown as expected - so the test whenClientAcctDispabled_throwsException passed.
I've added the following logical assert method to the test and used it everyplace I expect the process to succeed.
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);                

    }
Michael McKay
@mckayERP
image.png
For the processBuilder error, when I make the following changes, the tests pass:
Note - ideally, I'd refactor the field name so it doesn't match the class name, but the changes show the idea.
e-Evolution
@e-Evolution
@mckayERP the change is ok , create the pull request please
Yamel Senih
@yamelsenih
Hik

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

Michael McKay
@mckayERP
@e-Evolution The pull request is prepared adempiere/adempiere#3322.
@e-Evolution Wow. That was fast! Thanks.
Michael McKay
@mckayERP
@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?
e-Evolution
@e-Evolution
@mckayERP , @yamelsenih know this subject , he said me will check
fly8monkey
@fly8monkey
Hi everybody, nice to meet you all. I start to learn about Adempiere, but can't access adempiere.net for installing tutorial, is its website still alive? Thanks you all.
Michael McKay
@mckayERP
@fly8monkey We are aware the site is down. You can access info at https://adempiere.gitbook.io/docs/ or http://wiki.adempiere.io/ADempiere_ERP
We had an issue when moving to a new DNS. I hope we can resolve it soon.
Yamel Senih
@yamelsenih

@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

nice