Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
svencc committed Nov 11, 2023
1 parent 9cb985e commit 5f40f59
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/test/java/com/recom/mapper/MapEntityMapperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public void testToEntity() throws JsonProcessingException {
assertEquals(objectMapper.writeValueAsString(rotationY), entityToTest.getRotationY());
assertEquals(objectMapper.writeValueAsString(rotationZ), entityToTest.getRotationZ());
assertEquals(objectMapper.writeValueAsString(coordinates), entityToTest.getCoordinates());
assertEquals(BigDecimal.valueOf(1.0), entityToTest.getCoordinateX());
assertEquals(BigDecimal.valueOf(2.0), entityToTest.getCoordinateY());
assertEquals(BigDecimal.valueOf(3.0), entityToTest.getCoordinateZ());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public void testToEntity() throws JsonProcessingException {
assertEquals(oceanHeight, entityToTest.getOceanHeight());
assertEquals(oceanBaseHeight, entityToTest.getOceanBaseHeight());
assertEquals(objectMapper.writeValueAsString(coordinates), entityToTest.getCoordinates());
assertEquals(BigDecimal.valueOf(1.0), entityToTest.getCoordinateX());
assertEquals(BigDecimal.valueOf(2.0), entityToTest.getCoordinateY());
assertEquals(BigDecimal.valueOf(3.0), entityToTest.getCoordinateZ());
}

@Test
Expand Down
22 changes: 22 additions & 0 deletions src/test/java/com/recom/mapper/MapperUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.recom.service.provider.StaticObjectMapperProvider;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.lang.Nullable;

import java.math.BigDecimal;
import java.util.ArrayList;
Expand Down Expand Up @@ -71,4 +72,25 @@ public void testBlankStringToNull() throws JsonProcessingException {
assertNull(MapperUtil.blankStringToNull(null));
}

@Test
public void testExtractCoordinateX() {
// Arrange & Act & Assert
assertNull(MapperUtil.extractCoordinateX(null));
assertEquals(BigDecimal.ONE, MapperUtil.extractCoordinateX(List.of(BigDecimal.ONE, BigDecimal.TWO, BigDecimal.TEN)));
}

@Test
public void testExtractCoordinateY() {
// Arrange & Act & Assert
assertNull(MapperUtil.extractCoordinateY(null));
assertEquals(BigDecimal.TWO, MapperUtil.extractCoordinateY(List.of(BigDecimal.ONE, BigDecimal.TWO, BigDecimal.TEN)));
}

@Test
public void testExtractCoordinateZ() {
// Arrange & Act & Assert
assertNull(MapperUtil.extractCoordinateZ(null));
assertEquals(BigDecimal.TEN, MapperUtil.extractCoordinateZ(List.of(BigDecimal.ONE, BigDecimal.TWO, BigDecimal.TEN)));
}

}

0 comments on commit 5f40f59

Please sign in to comment.