Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Jun 24, 2024
2 parents 3a07516 + ce404ee commit 479494b
Show file tree
Hide file tree
Showing 32 changed files with 408 additions and 358 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,23 @@ jobs:
java-version: 17
cache: "maven"

- uses: Keeper-Security/ksm-action@v1
env:
KSM_CONFIG: ${{ secrets.KSM_CONFIG }}
if: ${{ env.KSM_CONFIG != '' }}
with:
keeper-secret-config: ${{ secrets.KSM_CONFIG }}
secrets: |
${{ vars.KEEPER_SONARCLOUD_RECORD_ID }}/field/password > env:SONAR_TOKEN
- name: Build with Sonarcloud
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
if: ${{ env.SONAR_TOKEN != '' }}
run: ./mvnw -B -ntp verify sonar:sonar

- name: Build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
if: ${{ env.SONAR_TOKEN == '' }}
run: ./mvnw -B -ntp verify
20 changes: 14 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- uses: Keeper-Security/ksm-action@v1
with:
keeper-secret-config: ${{ secrets.KSM_CONFIG }}
secrets: |
${{ vars.KEEPER_SONARCLOUD_RECORD_ID }}/field/password > env:SONAR_TOKEN
${{ vars.KEEPER_OSSRH_RECORD_ID }}/field/login > env:MAVEN_USERNAME
${{ vars.KEEPER_OSSRH_RECORD_ID }}/field/password > env:MAVEN_PASSWORD
${{ vars.KEEPER_GPG_ARTIFACT_SIGNING_RECORD_ID }}/field/login > env:GPG_KEYNAME
${{ vars.KEEPER_GPG_ARTIFACT_SIGNING_RECORD_ID }}/custom_field/gpg-private-key > env:GPG_PRIVATE_KEY
${{ vars.KEEPER_GPG_ARTIFACT_SIGNING_RECORD_ID }}/field/password > env:MAVEN_GPG_PASSPHRASE
- name: Setup Java
uses: actions/setup-java@v4
with:
Expand All @@ -28,15 +40,11 @@ jobs:
cache: "maven"
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USERNAME # env variable for username in deploy
server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy
gpg-private-key: ${{ secrets.gpg_private_key }} # Value of the GPG private key to import
server-password: MAVEN_PASSWORD # env variable for token in deploy
gpg-private-key: ${{ env.GPG_PRIVATE_KEY }} # Value of the GPG private key to import
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase

- name: Build and deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
MAVEN_USERNAME: ${{ secrets.ossrh_username }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.ossrh_password }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.gpg_passphrase }}
run: ./mvnw -B -ntp deploy sonar:sonar
17 changes: 11 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,25 @@ jobs:
with:
ref: ${{ github.event.inputs.tag }}

- uses: Keeper-Security/ksm-action@v1
with:
keeper-secret-config: ${{ secrets.KSM_CONFIG }}
secrets: |
${{ vars.KEEPER_OSSRH_RECORD_ID }}/field/login > env:MAVEN_USERNAME
${{ vars.KEEPER_OSSRH_RECORD_ID }}/field/password > env:MAVEN_PASSWORD
${{ vars.KEEPER_GPG_ARTIFACT_SIGNING_RECORD_ID }}/field/login > env:GPG_KEYNAME
${{ vars.KEEPER_GPG_ARTIFACT_SIGNING_RECORD_ID }}/custom_field/gpg-private-key > env:GPG_PRIVATE_KEY
${{ vars.KEEPER_GPG_ARTIFACT_SIGNING_RECORD_ID }}/field/password > env:MAVEN_GPG_PASSPHRASE
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: 17
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USERNAME # env variable for username in deploy
server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy
gpg-private-key: ${{ secrets.gpg_private_key }} # Value of the GPG private key to import
server-password: ${{ env.GPG_PRIVATE_KEY }} # Value of the GPG private key to import
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase

- name: Publish tag
env:
MAVEN_USERNAME: ${{ secrets.ossrh_username }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.ossrh_password }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.gpg_passphrase }}
run: ./mvnw -ntp --batch-mode deploy -Prelease
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,40 @@ Before contributing, read the [guidelines](CONTRIBUTING.md).

This repository follows the [GitFlow branching strategy](https://gitversion.net/docs/learn/branching-strategies/gitflow/examples).

### Regenerate Assert classes

You may want to regenerate Assert classes after modifying a model element. To do so, you can use the [AssertJ](https://joel-costigliola.github.io/assertj/assertj-assertions-generator-maven-plugin.html#quickstart) plugin.

1. First, run `./mvnw clean compile` to make sure the classes are found.
2. Delete the classes you want to regenerate.
3. Then edit the project's pom.xml and add the plugin configuration in the `build` section with the classes/packages you want to regenerate. E.g., in `application-model/pom.xml` add:
```xml
<plugin>
<groupId>org.assertj</groupId>
<artifactId>assertj-assertions-generator-maven-plugin</artifactId>
<version>2.2.0</version>
<configuration>
<classes>
<param>org.bonitasoft.engine.business.application.impl.ApplicationLinkImpl</param>
<param>org.bonitasoft.engine.business.application.xml.ApplicationLinkNode</param>
<param>org.bonitasoft.engine.business.application.xml.ApplicationNodeContainer</param>
</classes>
<generateAssertions>true</generateAssertions>
<generateBddAssertions>false</generateBddAssertions>
<generateSoftAssertions>false</generateSoftAssertions>
<generateJUnitSoftAssertions>false</generateJUnitSoftAssertions>
<hierarchical>false</hierarchical>
<targetDir>application-model/src/test/java</targetDir>
<generateAssertionsForAllFields>true</generateAssertionsForAllFields>
</configuration>
</plugin>
```
4. Then run the following command to regenerate the Assert classes: `./mvnw assertj:generate-assertions -f application-model/pom.xml` (adapt `-f` to your project)
5. Remove the `@javax.annotation.Generated` annotation from the generated classes and the generated `Assertions.java` file.
6. Format with `./mvnw spotless:apply`.
7. Make sure the generated classes satisfy your needs and that you did not corrupt other classes.
8. Restore the original state of the project's pom.xml file.

### Release

To release a new version, maintainers may use the Release and Publication GitHub actions.
Expand Down
2 changes: 1 addition & 1 deletion application-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.bonitasoft.engine</groupId>
<artifactId>bonita-artifacts-model-parent</artifactId>
<version>1.1.0</version>
<version>1.1.1</version>
</parent>
<artifactId>bonita-application-model</artifactId>
<name>Bonita Application Model</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
package org.bonitasoft.engine.business.application;

/**
* Contains the meta information of an advanced Bonita Living Application.
* Contains the meta information of a Bonita Living Application as a link.
*/
public interface AdvancedApplication extends IApplication {
public interface ApplicationLink extends IApplication {
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
**/
package org.bonitasoft.engine.business.application.impl;

import org.bonitasoft.engine.business.application.AdvancedApplication;
import org.bonitasoft.engine.business.application.ApplicationLink;

/**
* Contains the meta information of an advanced Bonita Living Application.
* Contains the meta information of a Bonita Living Application as a link.
*/
public class AdvancedApplicationImpl extends AbstractApplicationImpl implements AdvancedApplication {
public class ApplicationLinkImpl extends AbstractApplicationImpl implements ApplicationLink {

private static final long serialVersionUID = -7508775735750437592L;

public AdvancedApplicationImpl(final String token, final String version, final String description) {
public ApplicationLinkImpl(final String token, final String version, final String description) {
super(token, version, description);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
import javax.xml.bind.annotation.XmlAccessorType;

/**
* Application node for advanced Bonita Living Application.
* Application node for Bonita Living Application as a link.
*/
@XmlAccessorType(XmlAccessType.FIELD)
public class AdvancedApplicationNode extends AbstractApplicationNode {
public class ApplicationLinkNode extends AbstractApplicationNode {

/*
* Super implementations of equals and hashCode are enough.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,35 +39,35 @@ public static interface IApplicationBuilder {
public AbstractApplicationNode create();
}

public static class AdvancedApplicationBuilder implements IApplicationBuilder {
public static class ApplicationLinkBuilder implements IApplicationBuilder {

private final AdvancedApplicationNode applicationNode;
private final ApplicationLinkNode applicationNode;

public AdvancedApplicationBuilder(String token, String displayName, String version) {
applicationNode = new AdvancedApplicationNode();
public ApplicationLinkBuilder(String token, String displayName, String version) {
applicationNode = new ApplicationLinkNode();
applicationNode.setToken(token);
applicationNode.setDisplayName(displayName);
applicationNode.setVersion(version);
applicationNode.setState(ApplicationState.ACTIVATED.name());
}

public AdvancedApplicationBuilder withDescription(String description) {
public ApplicationLinkBuilder withDescription(String description) {
applicationNode.setDescription(description);
return this;
}

public AdvancedApplicationBuilder withIconPath(String iconPath) {
public ApplicationLinkBuilder withIconPath(String iconPath) {
applicationNode.setIconPath(iconPath);
return this;
}

public AdvancedApplicationBuilder withProfile(String profile) {
public ApplicationLinkBuilder withProfile(String profile) {
applicationNode.setProfile(profile);
return this;
}

@Override
public AdvancedApplicationNode create() {
public ApplicationLinkNode create() {
return applicationNode;
}

Expand Down Expand Up @@ -182,8 +182,8 @@ public static ApplicationNodeContainerBuilder newApplicationContainer() {
return new ApplicationNodeContainerBuilder();
}

public static AdvancedApplicationBuilder newAdvancedApplication(String token, String displayName, String version) {
return new AdvancedApplicationBuilder(token, displayName, version);
public static ApplicationLinkBuilder newApplicationLink(String token, String displayName, String version) {
return new ApplicationLinkBuilder(token, displayName, version);
}

public static ApplicationBuilder newApplication(String token, String displayName, String version) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@
public class ApplicationNodeContainer {

@XmlElements({
@XmlElement(name = "advancedApplication", type = AdvancedApplicationNode.class),
@XmlElement(name = "applicationLink", type = ApplicationLinkNode.class),
@XmlElement(name = "application", type = ApplicationNode.class) })
private final List<AbstractApplicationNode> allApplications;

public ApplicationNodeContainer() {
this.allApplications = new ArrayList<>();
}

public List<AdvancedApplicationNode> getAdvancedApplications() {
return allApplications.stream().filter(AdvancedApplicationNode.class::isInstance)
.map(AdvancedApplicationNode.class::cast).collect(Collectors.toList());
public List<ApplicationLinkNode> getApplicationLinks() {
return allApplications.stream().filter(ApplicationLinkNode.class::isInstance)
.map(ApplicationLinkNode.class::cast).collect(Collectors.toList());
}

public List<ApplicationNode> getApplications() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.tuple;
import static org.bonitasoft.engine.business.application.xml.ApplicationNodeBuilder.newAdvancedApplication;
import static org.bonitasoft.engine.business.application.xml.ApplicationNodeBuilder.newApplication;
import static org.bonitasoft.engine.business.application.xml.ApplicationNodeBuilder.newApplicationContainer;
import static org.bonitasoft.engine.business.application.xml.ApplicationNodeBuilder.newApplicationLink;

import javax.xml.bind.UnmarshalException;

Expand All @@ -32,12 +32,12 @@ class ApplicationNodeContainerConverterTest {
@Test
void should_marshall_applicationContainer_to_xml() throws Exception {
try (var inputStream = ApplicationNodeContainerConverterTest.class
.getResourceAsStream("/advancedApplication.xml")) {
.getResourceAsStream("/applicationLink.xml")) {
assertThat(inputStream).isNotNull();
var expectedXml = new String(inputStream.readAllBytes());

final byte[] xml = converter.marshallToXML(newApplicationContainer()
.havingApplications(newAdvancedApplication("myApp", "My App", "1.0")).create());
.havingApplications(newApplicationLink("myApp", "My App", "1.0")).create());

assertThat(xml).isNotNull();
assertThat(new String(xml)).isEqualToIgnoringNewLines(expectedXml);
Expand All @@ -47,12 +47,12 @@ void should_marshall_applicationContainer_to_xml() throws Exception {
@Test
void should_unmarshall_xml_into_applicationContainer() throws Exception {
try (var inputStream = ApplicationNodeContainerConverterTest.class
.getResourceAsStream("/advancedApplication.xml")) {
.getResourceAsStream("/applicationLink.xml")) {
assertThat(inputStream).isNotNull();
final ApplicationNodeContainer container = converter.unmarshallFromXML(inputStream.readAllBytes());

assertThat(container).isNotNull();
assertThat(container.getAdvancedApplications()).extracting("token", "displayName", "version")
assertThat(container.getApplicationLinks()).extracting("token", "displayName", "version")
.contains(tuple("myApp", "My App", "1.0"));
}
}
Expand Down Expand Up @@ -92,7 +92,7 @@ void should_marshall_mixedApplicationContainer_to_xml() throws Exception {

final byte[] xml = converter.marshallToXML(newApplicationContainer()
.havingApplications(newApplication("myApp", "My App", "1.0"),
newAdvancedApplication("myAdvancedApp", "My App 2", "2.0"))
newApplicationLink("myLinkedApp", "My App 2", "2.0"))
.create());

assertThat(xml).isNotNull();
Expand All @@ -109,14 +109,14 @@ void should_unmarshall_xml_into_mixedApplicationContainer() throws Exception {

assertThat(container).isNotNull();
assertThat(container.getAllApplications()).extracting("token", "displayName", "version")
.containsExactly(tuple("myApp", "My App", "1.0"), tuple("myAdvancedApp", "My App 2", "2.0"));
.containsExactly(tuple("myApp", "My App", "1.0"), tuple("myLinkedApp", "My App 2", "2.0"));
}
}

@Test
void should_fail_unmarshall_xml_into_applicationContainer() throws Exception {
try (var inputStream = ApplicationNodeContainerConverterTest.class
.getResourceAsStream("/badAdvancedApplication.xml")) {
.getResourceAsStream("/badApplicationLink.xml")) {
assertThat(inputStream).isNotNull();
assertThatExceptionOfType(UnmarshalException.class)
.isThrownBy(() -> converter.unmarshallFromXML(inputStream.readAllBytes()));
Expand Down
Loading

0 comments on commit 479494b

Please sign in to comment.