Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParamete
case TAB -> toTabInfos(identifiable);
case FORM -> toFormInfos(identifiable);
case LIST -> ElementInfosMapper.toInfosWithType(identifiable);
default -> throw new UnsupportedOperationException("TODO");
default -> throw handleUnsupportedInfoType(infoTypeParameters.getInfoType(), "Battery");
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import static org.gridsuite.network.map.dto.InfoTypeParameters.QUERY_PARAM_LOAD_OPERATIONAL_LIMIT_GROUPS;
import static org.gridsuite.network.map.dto.common.CurrentLimitsData.Applicability.SIDE1;
import static org.gridsuite.network.map.dto.common.CurrentLimitsData.Applicability.SIDE2;
import static org.gridsuite.network.map.dto.utils.ElementUtils.handleUnsupportedInfoType;
import static org.gridsuite.network.map.dto.utils.ElementUtils.mapCountry;
import static org.gridsuite.network.map.dto.utils.ExtensionUtils.buildQualityInfos;

Expand All @@ -44,7 +45,7 @@ public static ElementInfos toData(@NonNull final Identifiable<?> identifiable,
.map(Boolean::valueOf).orElse(false);
return switch (infoTypeParameters.getInfoType()) {
case TAB -> toTabInfos(branch, dcPowerFactor, loadOperationalLimitGroups);
default -> throw new UnsupportedOperationException("TODO");
default -> throw handleUnsupportedInfoType(infoTypeParameters.getInfoType(), "Branch");
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.gridsuite.network.map.dto.utils.ElementUtils;

import static org.gridsuite.network.map.dto.utils.ElementUtils.getProperties;
import static org.gridsuite.network.map.dto.utils.ElementUtils.handleUnsupportedInfoType;
import static org.gridsuite.network.map.dto.utils.ExtensionUtils.toMeasurement;

/**
Expand All @@ -34,7 +35,7 @@ public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParamete
case FORM -> toFormInfos(identifiable);
case LIST -> ElementInfosMapper.toListInfos(identifiable);
case OPERATING_STATUS -> ElementInfosMapper.toInfosWithOperatingStatus(identifiable);
default -> throw new UnsupportedOperationException("TODO");
default -> throw handleUnsupportedInfoType(infoTypeParameters.getInfoType(), "BusBarSection");
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
import java.util.Optional;

import static org.gridsuite.network.map.dto.InfoTypeParameters.QUERY_PARAM_LOAD_NETWORK_COMPONENTS;
import static org.gridsuite.network.map.dto.utils.ElementUtils.getProperties;
import static org.gridsuite.network.map.dto.utils.ElementUtils.mapCountry;
import static org.gridsuite.network.map.dto.utils.ElementUtils.*;

/**
* @author Hugo Marcellin <hugo.marcelin at rte-france.com>
Expand All @@ -34,7 +33,7 @@ public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParamete
return switch (infoTypeParameters.getInfoType()) {
case LIST -> ElementInfosMapper.toListInfos(identifiable);
case TAB -> toTabInfos(identifiable, shouldLoadNetworkComponents);
default -> throw new UnsupportedOperationException("TODO");
default -> throw handleUnsupportedInfoType(infoTypeParameters.getInfoType(), "Bus");
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParamete
return switch (infoTypeParameters.getInfoType()) {
case TAB -> toTabInfos(identifiable);
case LIST -> ElementInfosMapper.toInfosWithType(identifiable);
default -> throw new UnsupportedOperationException("TODO");
default -> throw handleUnsupportedInfoType(infoTypeParameters.getInfoType(), "DanglingLine");
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParamete
case TAB -> toTabInfos(identifiable, loadRegulatingTerminals);
case FORM -> toFormInfos(identifiable);
case LIST -> ElementInfosMapper.toInfosWithType(identifiable);
default -> throw new UnsupportedOperationException("TODO");
default -> throw handleUnsupportedInfoType(infoTypeParameters.getInfoType(), "Generator");
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParamete
case MAP -> toMapInfos(identifiable);
case LIST -> ElementInfosMapper.toListInfos(identifiable);
case OPERATING_STATUS -> toOperatingStatusInfos(identifiable);
default -> throw new UnsupportedOperationException("TODO");
default -> throw handleUnsupportedInfoType(infoTypeParameters.getInfoType(), "Hvdc");
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.gridsuite.network.map.dto.definition.hvdc.hvdclcc.HvdcLccFormInfos;

import static org.gridsuite.network.map.dto.utils.ElementUtils.getProperties;
import static org.gridsuite.network.map.dto.utils.ElementUtils.handleUnsupportedInfoType;

/**
* @author Ghazwa Rehili <ghazwa.rehili at rte-france.com>
Expand All @@ -26,7 +27,7 @@ public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParamete
return switch (infoTypeParameters.getInfoType()) {
case FORM -> toFormInfos(identifiable);
case LIST -> ElementInfosMapper.toListInfos(identifiable);
default -> throw new UnsupportedOperationException("TODO");
default -> throw handleUnsupportedInfoType(infoTypeParameters.getInfoType(), "HVDC LCC");
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.gridsuite.network.map.dto.utils.ExtensionUtils;

import static org.gridsuite.network.map.dto.utils.ElementUtils.getProperties;
import static org.gridsuite.network.map.dto.utils.ElementUtils.handleUnsupportedInfoType;

/**
* @author Ghazwa Rehili <ghazwa.rehili at rte-france.com>
Expand All @@ -27,7 +28,7 @@ public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParamete
return switch (infoTypeParameters.getInfoType()) {
case FORM -> toFormInfos(identifiable);
case LIST -> ElementInfosMapper.toListInfos(identifiable);
default -> throw new UnsupportedOperationException("TODO");
default -> throw handleUnsupportedInfoType(infoTypeParameters.getInfoType(), "HVDC VSC");
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParamete
case TAB -> toTabInfos(identifiable);
case LIST -> ElementInfosMapper.toInfosWithType(identifiable);
case FORM -> toFormInfos(identifiable);
default -> throw new UnsupportedOperationException("TODO");
default -> throw handleUnsupportedInfoType(infoTypeParameters.getInfoType(), "LccConverterStation");
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParamete
case LIST -> ElementInfosMapper.toListInfos(identifiable);
case OPERATING_STATUS -> toOperatingStatusInfos(identifiable);
case TOOLTIP -> toTooltipInfos(identifiable, dcPowerFactor);
default -> throw new UnsupportedOperationException("TODO");
default -> throw handleUnsupportedInfoType(infoTypeParameters.getInfoType(), "Line");
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParamete
case TAB -> toTabInfos(identifiable);
case FORM -> toFormInfos(identifiable);
case LIST -> ElementInfosMapper.toInfosWithType(identifiable);
default -> throw new UnsupportedOperationException("TODO");
default -> throw handleUnsupportedInfoType(infoTypeParameters.getInfoType(), "Load");
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParamete
case TAB -> toTabInfos(identifiable);
case FORM -> toFormInfos(identifiable);
case LIST -> ElementInfosMapper.toInfosWithType(identifiable);
default -> throw new UnsupportedOperationException("TODO");
default -> throw handleUnsupportedInfoType(infoTypeParameters.getInfoType(), "ShuntCompensator");
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParamete
case TAB -> toTabInfos(identifiable);
case FORM -> toFormInfos(identifiable);
case LIST -> ElementInfosMapper.toInfosWithType(identifiable);
default -> throw new UnsupportedOperationException("TODO");
default -> throw handleUnsupportedInfoType(infoTypeParameters.getInfoType(), "StaticVarCompensator");
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
import java.util.Map;
import java.util.stream.Collectors;

import static org.gridsuite.network.map.dto.utils.ElementUtils.getProperties;
import static org.gridsuite.network.map.dto.utils.ElementUtils.mapCountry;
import static org.gridsuite.network.map.dto.utils.ElementUtils.*;

/**
* @author Slimane Amar <slimane.amar at rte-france.com>
Expand All @@ -34,7 +33,7 @@ public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParamete
case MAP -> toMapInfos(identifiable);
case FORM -> toFormInfos(identifiable);
case LIST -> ElementInfosMapper.toListInfos(identifiable);
default -> throw new UnsupportedOperationException("TODO");
default -> throw handleUnsupportedInfoType(infoTypeParameters.getInfoType(), "Substation");
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParamete
case LIST -> ElementInfosMapper.toListInfos(identifiable);
case OPERATING_STATUS -> toOperatingStatusInfos(identifiable);
case TAB -> toTabInfos(identifiable);
default -> throw new UnsupportedOperationException("TODO");
default -> throw handleUnsupportedInfoType(infoTypeParameters.getInfoType(), "ThreeWindingsTransformer");
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParamete
case TAB -> toTabInfos(identifiable, dcPowerFactor);
case MAP -> toMapInfos(identifiable, dcPowerFactor);
case LIST -> ElementInfosMapper.toInfosWithType(identifiable);
default -> throw new UnsupportedOperationException("TODO");
default -> throw handleUnsupportedInfoType(infoTypeParameters.getInfoType(), "TieLine");
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParamete
case TOOLTIP -> toTooltipInfos(identifiable, dcPowerFactor);
case TAB -> toTabInfos(identifiable, dcPowerFactor, loadOperationalLimitGroups);
case FORM -> toFormInfos(identifiable);
default -> throw new UnsupportedOperationException("TODO");
default -> throw handleUnsupportedInfoType(infoTypeParameters.getInfoType(), "TwoWindingsTransformer");
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParamete
case FORM -> toFormInfos(identifiable);
case LIST -> ElementInfosMapper.toListInfos(identifiable);
case MAP -> toMapInfos(identifiable);
default -> throw new UnsupportedOperationException("TODO");
default -> throw handleUnsupportedInfoType(infoTypeParameters.getInfoType(), "VoltageLevel");
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParamete
case TAB -> toTabInfos(identifiable);
case FORM -> toFormInfos(identifiable);
case LIST -> ElementInfosMapper.toInfosWithType(identifiable);
default -> throw new UnsupportedOperationException("TODO");
default -> throw handleUnsupportedInfoType(infoTypeParameters.getInfoType(), "VscConverterStation");
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import com.powsybl.iidm.network.*;
import com.powsybl.iidm.network.extensions.ConnectablePosition;
import org.gridsuite.network.map.dto.ElementInfos;
import org.gridsuite.network.map.dto.common.ReactiveCapabilityCurveMapData;
import org.gridsuite.network.map.dto.common.TapChangerData;
import org.gridsuite.network.map.dto.common.TapChangerStepData;
Expand Down Expand Up @@ -209,4 +210,10 @@ public static Substation findFirstSubstation(List<Terminal> terminals) {
.flatMap(Function.identity())
.orElse(null);
}

public static UnsupportedOperationException handleUnsupportedInfoType(@NonNull final ElementInfos.InfoType infoType, @NonNull final String elementTypeName) {
return new UnsupportedOperationException(
"InfoType '" + infoType + "' is not supported for " + elementTypeName + " elements"
);
}
}
31 changes: 31 additions & 0 deletions src/test/java/org/gridsuite/network/map/MapperTestUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Copyright (c) 2025, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
* SPDX-License-Identifier: MPL-2.0
*/
package org.gridsuite.network.map;

/**
* @author Achour Berrahma <achour.berrahma at rte-france.com>
*/
public final class MapperTestUtils {
private MapperTestUtils() {
throw new InstantiationError("Utility Class cannot be instantiated.");
}

/**
* Check if the exception message indicates an unsupported InfoType.
* Matches patterns like: "InfoType 'X' is not supported for Y elements"
*
* @param message the exception message to check
* @return true if the message indicates an unsupported InfoType
*/
public static boolean isUnsupportedInfoTypeMessage(final String message) {
return message != null &&
message.contains("InfoType") &&
message.contains("is not supported for") &&
message.contains("elements");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.assertj.core.api.WithAssertions;
import org.assertj.core.api.WithAssumptions;
import org.gridsuite.network.map.MapperTestUtils;
import org.gridsuite.network.map.dto.ElementInfos;
import org.gridsuite.network.map.dto.ElementInfos.InfoType;
import org.gridsuite.network.map.dto.InfoTypeParameters;
Expand Down Expand Up @@ -106,7 +107,7 @@ void shouldHandleInfoType(final InfoType infoType) throws Throwable {
}
} catch (final InvocationTargetException ex) {
final Throwable cause = ex.getCause();
if (cause instanceof UnsupportedOperationException && "TODO".equals(cause.getMessage())) {
if (cause instanceof UnsupportedOperationException && MapperTestUtils.isUnsupportedInfoTypeMessage(cause.getMessage())) {
throw new TestAbortedException("Type not supported by this mapper.");
} else if (!(cause instanceof InterruptTest)) {
throw ex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.assertj.core.api.WithAssertions;
import org.assertj.core.api.WithAssumptions;
import org.gridsuite.network.map.MapperTestUtils;
import org.gridsuite.network.map.dto.ElementInfos;
import org.gridsuite.network.map.dto.ElementInfos.InfoType;
import org.gridsuite.network.map.dto.InfoTypeParameters;
Expand Down Expand Up @@ -105,7 +106,7 @@ void shouldHandleInfoType(final InfoType infoType) throws Throwable {
}
} catch (final InvocationTargetException ex) {
final Throwable cause = ex.getCause();
if (cause instanceof UnsupportedOperationException && "TODO".equals(cause.getMessage())) {
if (cause instanceof UnsupportedOperationException && MapperTestUtils.isUnsupportedInfoTypeMessage(cause.getMessage())) {
throw new TestAbortedException("Type not supported by this mapper.");
} else if (!(cause instanceof InterruptTest)) {
throw ex;
Expand Down