Skip to content

Commit

Permalink
Merge pull request #131 from com-pas/dependabot/maven/powsybl.version…
Browse files Browse the repository at this point in the history
…-4.5.0

Bump powsybl.version from 4.4.0 to 4.5.0
  • Loading branch information
Dennis Labordus authored Nov 10, 2021
2 parents 0ec1b50 + 6712dac commit 1b046a7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SPDX-License-Identifier: Apache-2.0
<jakarta-cdi-api.version>2.0.2</jakarta-cdi-api.version>
<apache.commons-io.version>2.11.0</apache.commons-io.version>
<slf4j.version>1.7.32</slf4j.version>
<powsybl.version>4.4.0</powsybl.version>
<powsybl.version>4.5.0</powsybl.version>
<mapstruct.version>1.4.2.Final</mapstruct.version>

<!-- Test -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.powsybl.commons.datasource.ReadOnlyMemDataSource;
import com.powsybl.triplestore.api.TripleStoreFactory;
import org.apache.commons.io.input.ReaderInputStream;
import org.lfenergy.compas.cim.mapping.exception.CompasCimMappingException;
import org.lfenergy.compas.cim.mapping.model.CimData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -20,6 +21,8 @@
import java.util.Map;
import java.util.stream.Collectors;

import static org.lfenergy.compas.cim.mapping.exception.CompasCimMappingErrorCode.NO_DATA_ERROR_CODE;

/**
* Class to read the CIM Model into a Java Object Model to be used further for converting it to IEC 61850.
*/
Expand All @@ -35,6 +38,9 @@ public class CgmesCimReader {
* @return The Cgmes Model that can be used to convert further to IEC 61850.
*/
public CgmesModel readModel(List<CimData> cimData) {
if (cimData == null || cimData.isEmpty()) {
throw new CompasCimMappingException(NO_DATA_ERROR_CODE, "No CIM Data passed!");
}
LOGGER.debug("Create a ReadOnlyDataSource from the input data.");
var cimContents = convertCimDataToMap(cimData);
var source = new ReadOnlyMemDataSource();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ public class CompasCimMappingErrorCode {
}

public static final String UNKNOWN_TYPE_ERROR_CODE = "CIM-0001";
public static final String NO_DATA_ERROR_CODE = "CIM-0002";
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.lfenergy.compas.cim.mapping.exception.CompasCimMappingException;
import org.lfenergy.compas.cim.mapping.model.CimData;
import org.mockito.InjectMocks;
import org.mockito.junit.jupiter.MockitoExtension;
Expand All @@ -17,6 +18,8 @@

import static java.util.Objects.requireNonNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.lfenergy.compas.cim.mapping.exception.CompasCimMappingErrorCode.NO_DATA_ERROR_CODE;

@ExtendWith(MockitoExtension.class)
class CgmesCimReaderTest {
Expand All @@ -36,12 +39,21 @@ void readModel_WhenReadingCimModel_ThenCgmesModelReturnedWithSubstations() throw
}

@Test
void readModel_WhenReadingWithoutCimModel_ThenCgmesModelReturnedWithoutSubstations() {
void readModel_WhenReadingWithEmptyCimDataList_ThenExceptionThrown() {
List<CimData> cimDataList = Collections.emptyList();

var result = cgmesCimReader.readModel(cimDataList);
var exception = assertThrows(CompasCimMappingException.class,
() -> cgmesCimReader.readModel(cimDataList));

assertEquals(NO_DATA_ERROR_CODE, exception.getErrorCode());
}

@Test
void readModel_WhenReadingWithNullList_ThenExceptionThrown() {
var exception = assertThrows(CompasCimMappingException.class,
() -> cgmesCimReader.readModel(null));

assertEquals(0, result.substations().size());
assertEquals(NO_DATA_ERROR_CODE, exception.getErrorCode());
}

private String readFile() throws IOException {
Expand Down

0 comments on commit 1b046a7

Please sign in to comment.