Skip to content

Commit

Permalink
Update powernode to 2.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
eschleb committed Sep 23, 2024
1 parent 01e1e91 commit a4f711e
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ atlassian-ide-plugin.xml

/magnolia-builders/target
/custom-definitions/target
/custom-definitions-spring/target/
/key-generator/target
27 changes: 27 additions & 0 deletions custom-definitions-spring/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.namics.oss.magnolia</groupId>
<artifactId>magnolia-definition-builders-parent</artifactId>
<version>1.2.2-SNAPSHOT</version>
</parent>

<artifactId>custom-definition-builders-spring</artifactId>


<dependencies>
<dependency>
<groupId>com.namics.oss.magnolia</groupId>
<artifactId>custom-definition-builders</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.google.common.base.Joiner;
import com.merkle.oss.magnolia.definition.custom.linkset.model.Link;
import com.merkle.oss.magnolia.definition.custom.linkset.model.LinkModel;
import org.springframework.stereotype.Component;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.merkle.oss.magnolia.definition.custom.linkset.model.util;

import java.util.Collections;
import java.util.Map;

import org.apache.http.client.utils.URIBuilder;

import com.machinezoo.noexception.Exceptions;
import com.merkle.oss.magnolia.definition.custom.linkset.model.Link;
import com.merkle.oss.magnolia.definition.custom.linkset.model.LinkModel;
import org.springframework.web.util.UriComponentsBuilder;

import java.util.Map;

public class ExtendedLinkQueryParamModifier {

Expand All @@ -28,11 +31,11 @@ private Link modify(final Link extendedLink, final Map<String, String> queryPara
}

private String setQueryParams(final String href, final Map<String, String> queryParams, final boolean replace) {
final UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromUriString(href);
final URIBuilder uriBuilder = Exceptions.wrap().get(() -> new URIBuilder(href));
if (replace) {
uriComponentsBuilder.replaceQuery(null);
uriBuilder.setParameters(Collections.emptyList());
}
queryParams.forEach(uriComponentsBuilder::queryParam);
return uriComponentsBuilder.toUriString();
queryParams.forEach(uriBuilder::addParameter);
return Exceptions.wrap().get(uriBuilder::build).toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.merkle.oss.magnolia.definition.custom.linkset.model.util;

import static org.junit.jupiter.api.Assertions.*;

import java.util.Map;

import org.junit.jupiter.api.Test;

import com.merkle.oss.magnolia.definition.custom.linkset.LinkTypes;
import com.merkle.oss.magnolia.definition.custom.linkset.model.Link;
import com.merkle.oss.magnolia.definition.custom.linkset.model.LinkModel;

class ExtendedLinkQueryParamModifierTest {
private static final Link LINK = new LinkModel(
"linkText",
"/de/test?param1=42",
"https://someDomain.com/de/test?param1=42",
false,
false,
LinkTypes.INTERNAL
);

@Test
void withAppend() {
assertEquals(
new LinkModel(
"linkText",
"/de/test?param1=42&param2=43",
"https://someDomain.com/de/test?param1=42&param2=43",
false,
false,
LinkTypes.INTERNAL
),
new ExtendedLinkQueryParamModifier().withAppend(LINK, Map.of("param2", "43"))
);
}

@Test
void withReplace() {
assertEquals(
new LinkModel(
"linkText",
"/de/test?param2=43",
"https://someDomain.com/de/test?param2=43",
false,
false,
LinkTypes.INTERNAL
),
new ExtendedLinkQueryParamModifier().withReplace(LINK, Map.of("param2", "43"))
);
}
}
6 changes: 4 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@
<modules>
<module>magnolia-builders</module>
<module>custom-definitions</module>
<module>key-generator</module>
</modules>
<module>key-generator</module>
<module>custom-definitions-spring</module>
</modules>

<properties>
<!-- (check for new versions: mvn versions:display-property-updates )-->

<magnolia.version>6.3.0</magnolia.version>
<magnolia.workflow.version>6.0.8</magnolia.workflow.version>
<spring.version>5.3.39</spring.version>
<merkle.powernode.version>2.1.1</merkle.powernode.version>
<java.poet.version>1.12.1</java.poet.version>
<jsr305.nullable.version>3.0.2</jsr305.nullable.version>
Expand Down

0 comments on commit a4f711e

Please sign in to comment.