Skip to content
Open
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
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
<dependency>
<groupId>com.amihaiemil.web</groupId>
<artifactId>eo-yaml</artifactId>
<version>5.2.1</version>
<version>6.0.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand All @@ -144,6 +144,11 @@
test
</scope>
</dependency>
<dependency>
<groupId>org.llorllale</groupId>
<artifactId>cactoos-matchers</artifactId>
<version>0.25</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
package org.fusionsoft.database.mapping.dbd;

import org.cactoos.map.MapEntry;
import org.fusionsoft.database.mapping.entries.ScalarEntry;
import org.fusionsoft.database.mapping.fields.DbdRootFields;
import org.fusionsoft.database.snapshot.DatabaseInfo;
import org.fusionsoft.database.snapshot.Objects;
import org.fusionsoft.lib.yaml.YamlMappingOfEntries;
import org.fusionsoft.lib.yaml.YamlPlainScalarOf;

/**
* The ways to construct DBD mapping.
Expand All @@ -41,9 +41,9 @@ public DbdRootMappingBuilt(
) {
super(
new YamlMappingOfEntries(
new ScalarEntry(
new MapEntry<>(
DbdRootFields.JSONSCHEMA,
new TextOfDbdDefaultJsonSchemaRef()
new YamlPlainScalarOf(new TextOfDbdDefaultJsonSchemaRef())
),
new MapEntry<>(
DbdRootFields.INFO,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@
*/
package org.fusionsoft.database.mapping.entries;

import com.amihaiemil.eoyaml.Yaml;
import com.amihaiemil.eoyaml.YamlNode;
import java.util.Map;
import org.cactoos.Scalar;
import org.cactoos.Text;
import org.cactoos.scalar.Sticky;
import org.cactoos.scalar.Unchecked;
import org.fusionsoft.lib.exception.NotImplemented;
import org.fusionsoft.lib.yaml.YamlPlainScalarOf;

/**
* The type of Map.Entry of Text -> YamlNode that can be constructed of
Expand All @@ -37,18 +34,18 @@ public class ScalarEntry implements Map.Entry<Text, YamlNode> {
private final Text text;

/**
* The Scalar of YamlNode encapsulated.
* The Scalar YamlNode encapsulated.
*/
private final Unchecked<YamlNode> node;
private final YamlNode node;

/**
* Instantiates a new Scalar entry.
* @param text The Text to be encapsulated.
* @param node The Scalar of YamlNode to be encapsulated.
* @param node The Scalar YamlNode to be encapsulated.
*/
private ScalarEntry(final Text text, final Scalar<YamlNode> node) {
private ScalarEntry(final Text text, final YamlNode node) {
this.text = text;
this.node = new Unchecked<>(new Sticky<>(node));
this.node = node;
}

/**
Expand All @@ -59,7 +56,7 @@ private ScalarEntry(final Text text, final Scalar<YamlNode> node) {
public ScalarEntry(final Text key, final Text value) {
this(
key,
() -> Yaml.createYamlScalarBuilder().addLine(value.asString()).buildPlainScalar()
new YamlPlainScalarOf(value)
);
}

Expand All @@ -70,7 +67,7 @@ public final Text getKey() {

@Override
public final YamlNode getValue() {
return this.node.value();
return this.node;
}

@Override
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/fusionsoft/lib/yaml/YamlNodeOfScalar.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public YamlNodeOfScalar(final org.cactoos.Scalar<YamlNode> scalar) {
this.scalar = new Unchecked<>(new Sticky<>(scalar));
}

@Override
public boolean isEmpty() {
return this.scalar.value().isEmpty();
}

@Override
public final Comment comment() {
return this.scalar.value().comment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ class DbdSchemasMappingOfObjectsTest {

/**
* Creates mapping identical to input.
* @throws Exception When can't.
*/
@Test
public void createsMappingIdenticalToInput() throws Exception {
public void createsMappingIdenticalToInput() {
final MappingOfExampleYaml yaml = new MappingOfExampleYaml();
Assertions.assertEquals(
new YamlMappingOfPath(yaml, "schemas").toString(),
Expand Down
54 changes: 54 additions & 0 deletions src/test/java/org/fusionsoft/lib/yaml/YamlPlainScalarOfTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (C) 2018-2021 FusionSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied.
*
* See the License for the specific language governing permissions
* and limitations under the License.
*/
package org.fusionsoft.lib.yaml;

import org.cactoos.Text;
import org.cactoos.map.MapEntry;
import org.cactoos.text.TextOf;
import org.fusionsoft.lib.exception.ValidationException;
import org.junit.jupiter.api.Test;
import org.llorllale.cactoos.matchers.Assertion;
import org.llorllale.cactoos.matchers.Throws;

/**
* The test for {@link YamlPlainScalarOf} class.
* @since 0.1
*/
class YamlPlainScalarOfTest {

/**
* Can use to string when decorate yaml node.
*/
@Test
public void canUseToStringWhenDecorateYamlNode() {
final Text text = new TextOf("ABDC");
new Assertion<>(
"???",
() -> {
throw new ValidationException(
new YamlMappingOfEntries(
new MapEntry<>(
text,
new YamlPlainScalarOf(text)
)
).toString()
);
},
new Throws<>(ValidationException.class)
).affirm();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
* and limitations under the License.
*/
/**
* Tests for yaml artefacts.
* Tests for {@link org.fusionsoft.lib.yaml.artefacts} package classes.
*/
package org.fusionsoft.lib.yaml.artefacts;
20 changes: 20 additions & 0 deletions src/test/java/org/fusionsoft/lib/yaml/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (C) 2018-2021 FusionSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied.
*
* See the License for the specific language governing permissions
* and limitations under the License.
*/

/**
* Tests for {@link org.fusionsoft.lib.yaml} package classes.
*/
package org.fusionsoft.lib.yaml;