Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(application): Rename AdvancedApplication to ApplicationLink #116

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Loading