Skip to content

Commit 95634b8

Browse files
committed
added unit tests. updated maven pom files. updated dependencies. added vaadin runner for intellij.
1 parent 6de365a commit 95634b8

File tree

5 files changed

+112
-1
lines changed

5 files changed

+112
-1
lines changed

.run/Vaadin Demo.run.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="Vaadin Demo" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
3+
<option name="FRAME_DEACTIVATION_UPDATE_POLICY" value="UpdateClassesAndResources" />
4+
<module name="jlmap-vaadin-demo" />
5+
<option name="SPRING_BOOT_MAIN_CLASS" value="io.github.makbn.vaadin.demo.Application" />
6+
<extension name="coverage">
7+
<pattern>
8+
<option name="PATTERN" value="io.github.makbn.vaadin.demo.*" />
9+
<option name="ENABLED" value="true" />
10+
</pattern>
11+
</extension>
12+
<method v="2">
13+
<option name="Make" enabled="true" />
14+
</method>
15+
</configuration>
16+
</component>

jlmap-api/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,11 @@
9393
<artifactId>junit-jupiter</artifactId>
9494
<scope>test</scope>
9595
</dependency>
96+
<dependency>
97+
<groupId>org.assertj</groupId>
98+
<artifactId>assertj-core</artifactId>
99+
<version>3.27.4</version>
100+
<scope>test</scope>
101+
</dependency>
96102
</dependencies>
97103
</project>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package io.github.makbn.jlmap.model.builder;
2+
3+
import io.github.makbn.jlmap.listener.JLAction;
4+
import io.github.makbn.jlmap.model.JLOptions;
5+
import org.junit.jupiter.api.Test;
6+
7+
import static org.assertj.core.api.Assertions.assertThat;
8+
9+
class JLCircleBuilderTest {
10+
11+
@Test
12+
void builder_withOptions_buildCircle() {
13+
var elementUniqueName = "circle";
14+
15+
var circleBuilder = new JLCircleBuilder()
16+
.setUuid(elementUniqueName)
17+
.setLat(10.2)
18+
.setLng(20.1)
19+
.setRadius(13)
20+
.setTransporter(() -> transport -> {
21+
})
22+
.withOptions(JLOptions.DEFAULT)
23+
.withCallbacks(jlCallbackBuilder -> {
24+
jlCallbackBuilder.on(JLAction.MOVE);
25+
jlCallbackBuilder.on(JLAction.ADD);
26+
jlCallbackBuilder.on(JLAction.REMOVE);
27+
});
28+
29+
assertThat(circleBuilder.buildJsElement()).isEqualTo("""
30+
let circle = L.circle([10.200000, 20.100000], { radius: 13.000000, fillOpacity: 0.2, draggable: false, closeButton: true, smoothFactor: 1.0, weight: 3, fill: true, opacity: 1.0, stroke: true, autoClose: true });
31+
this.circle = circle;
32+
circle.uuid = 'circle';
33+
// callback start
34+
this.circle.on('move', e => this.jlMapElement.$server.eventHandler('move', 'jlcircle', e.target.uuid, this.map.getZoom(),
35+
JSON.stringify(e.latlng || {}),
36+
JSON.stringify(this.map.getBounds())
37+
));
38+
39+
this.circle.on('add', e => this.jlMapElement.$server.eventHandler('add', 'jlcircle', e.target.uuid, this.map.getZoom(),
40+
JSON.stringify(e.latlng || {}),
41+
JSON.stringify(this.map.getBounds())
42+
));
43+
44+
this.circle.on('remove', e => this.jlMapElement.$server.eventHandler('remove', 'jlcircle', e.target.uuid, this.map.getZoom(),
45+
JSON.stringify(e.latlng || {}),
46+
JSON.stringify(this.map.getBounds())
47+
));
48+
49+
// callback end
50+
circle.addTo(this.map);
51+
""");
52+
53+
}
54+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package io.github.makbn.jlmap.model.builder;
2+
3+
import io.github.makbn.jlmap.model.JLOptions;
4+
import org.junit.jupiter.api.Test;
5+
6+
import static org.assertj.core.api.Assertions.assertThat;
7+
import static org.assertj.core.api.AssertionsForClassTypes.within;
8+
9+
class JLOptionsBuilderTest {
10+
11+
@Test
12+
void optionBuilder_default_shouldGenerateTheMap() {
13+
JLOptionsBuilder builder = new JLOptionsBuilder();
14+
builder.setOption(JLOptions.DEFAULT);
15+
16+
assertThat(builder.build()).isNotNull()
17+
.isNotEmpty()
18+
.satisfies(actualMap -> {
19+
assertThat(actualMap).containsEntry("autoClose", true);
20+
assertThat(actualMap).containsEntry("closeButton", true);
21+
assertThat(actualMap).containsEntry("draggable", false);
22+
assertThat(actualMap).containsEntry("fill", true);
23+
assertThat(actualMap).containsEntry("fillOpacity", 0.2).hasEntrySatisfying("fillOpacity", value ->
24+
assertThat((Double) value).isCloseTo(0.2, within(0.00001)));
25+
assertThat(actualMap).containsEntry("opacity", 1.0).hasEntrySatisfying("opacity", value ->
26+
assertThat((Double) value).isCloseTo(1.0, within(0.00001)));
27+
assertThat(actualMap).containsEntry("smoothFactor", 1.0).hasEntrySatisfying("smoothFactor", value ->
28+
assertThat((Double) value).isCloseTo(1.0, within(0.00001)));
29+
assertThat(actualMap).containsEntry("stroke", true);
30+
assertThat(actualMap).containsEntry("weight", 3);
31+
});
32+
}
33+
}

pom.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@
1313
<modules>
1414
<module>jlmap-api</module>
1515
<module>jlmap-fx</module>
16+
<module>jlmap-vaadin</module>
17+
<module>jlmap-vaadin-demo</module>
1618
</modules>
1719

1820
<properties>
1921
<maven.compiler.source>17</maven.compiler.source>
2022
<maven.compiler.target>17</maven.compiler.target>
2123
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2224
<javafx.version>19.0.2.1</javafx.version>
23-
<lombok.version>1.18.34</lombok.version>
25+
<lombok.version>1.18.38</lombok.version>
2426
</properties>
2527

2628
<developers>

0 commit comments

Comments
 (0)