diff --git a/README.md b/README.md index c2405443..915feb95 100644 --- a/README.md +++ b/README.md @@ -283,6 +283,8 @@ They depend on several other libraries so I suggest you are going for the Maven # News and noteworthy +* v9.1.3 - 2023-12-10 + * Fixed the state in `ESMPTransportProfile` * v9.1.2 - 2023-12-06 * Added new submodule `peppol-mlr`. It contains data structures to read and write Peppol Message Level Response messages. * v9.1.1 - 2023-11-22 diff --git a/peppol-commons/src/main/java/com/helger/peppol/smp/ESMPTransportProfile.java b/peppol-commons/src/main/java/com/helger/peppol/smp/ESMPTransportProfile.java index ee46b558..90f26c43 100644 --- a/peppol-commons/src/main/java/com/helger/peppol/smp/ESMPTransportProfile.java +++ b/peppol-commons/src/main/java/com/helger/peppol/smp/ESMPTransportProfile.java @@ -36,14 +36,7 @@ public enum ESMPTransportProfile implements ISMPTransportProfile * The Peppol START transport profile */ @Deprecated (forRemoval = false) - TRANSPORT_PROFILE_START("busdox-transport-start", "START") - { - @Override - public boolean isDeprecated () - { - return true; - } - }, + TRANSPORT_PROFILE_START("busdox-transport-start", "START", ESMPTransportProfileState.DEPRECATED), /** * The Peppol AS2 transport profile v1 (SHA-1).
@@ -51,14 +44,7 @@ public boolean isDeprecated () * Removed from Peppol per 2023-02-24 */ @Deprecated (forRemoval = false) - TRANSPORT_PROFILE_AS2("busdox-transport-as2-ver1p0", "Peppol AS2 v1") - { - @Override - public boolean isDeprecated () - { - return true; - } - }, + TRANSPORT_PROFILE_AS2("busdox-transport-as2-ver1p0", "Peppol AS2 v1", ESMPTransportProfileState.DEPRECATED), /** * The Peppol AS2 v2 transport profile v2 (SHA-256).
@@ -66,28 +52,14 @@ public boolean isDeprecated () * Removed from Peppol per 2023-02-24 */ @Deprecated (forRemoval = false) - TRANSPORT_PROFILE_AS2_V2("busdox-transport-as2-ver2p0", "Peppol AS2 v2") - { - @Override - public boolean isDeprecated () - { - return true; - } - }, + TRANSPORT_PROFILE_AS2_V2("busdox-transport-as2-ver2p0", "Peppol AS2 v2", ESMPTransportProfileState.DEPRECATED), /** The AS4 transport profile - too unspecific. Don't use */ @Deprecated (forRemoval = false) - TRANSPORT_PROFILE_AS4("busdox-transport-ebms3-as4", "AS4") - { - @Override - public boolean isDeprecated () - { - return true; - } - }, + TRANSPORT_PROFILE_AS4("busdox-transport-ebms3-as4", "AS4", ESMPTransportProfileState.DEPRECATED), /** The CEF AS4 transport profile */ - TRANSPORT_PROFILE_BDXR_AS4 ("bdxr-transport-ebms3-as4-v1p0", "CEF AS4"), + TRANSPORT_PROFILE_BDXR_AS4 ("bdxr-transport-ebms3-as4-v1p0", "CEF AS4", ESMPTransportProfileState.ACTIVE), /** * The Peppol AS4 profile v1. @@ -95,24 +67,22 @@ public boolean isDeprecated () * @deprecated for {@link #TRANSPORT_PROFILE_PEPPOL_AS4_V2} */ @Deprecated (forRemoval = false) - TRANSPORT_PROFILE_PEPPOL_AS4("peppol-transport-as4-v1_0", "Peppol AS4 v1") - { - @Override - public boolean isDeprecated () - { - return true; - } - }, + TRANSPORT_PROFILE_PEPPOL_AS4("peppol-transport-as4-v1_0", "Peppol AS4 v1", ESMPTransportProfileState.DEPRECATED), + /** The Peppol AS4 profile v2 */ - TRANSPORT_PROFILE_PEPPOL_AS4_V2 ("peppol-transport-as4-v2_0", "Peppol AS4 v2"); + TRANSPORT_PROFILE_PEPPOL_AS4_V2 ("peppol-transport-as4-v2_0", "Peppol AS4 v2", ESMPTransportProfileState.ACTIVE); private final String m_sID; private final String m_sName; + private final ESMPTransportProfileState m_eState; - ESMPTransportProfile (@Nonnull @Nonempty final String sID, @Nonnull @Nonempty final String sName) + ESMPTransportProfile (@Nonnull @Nonempty final String sID, + @Nonnull @Nonempty final String sName, + @Nonnull final ESMPTransportProfileState eState) { m_sID = sID; m_sName = sName; + m_eState = eState; } @Nonnull @@ -135,6 +105,12 @@ public String getName () return m_sName; } + @Nonnull + public ESMPTransportProfileState getState () + { + return m_eState; + } + /** * Find the pre-defined transport profile with the passed ID. * diff --git a/peppol-commons/src/test/java/com/helger/peppol/smp/ESMPTransportProfileTest.java b/peppol-commons/src/test/java/com/helger/peppol/smp/ESMPTransportProfileTest.java new file mode 100644 index 00000000..60923096 --- /dev/null +++ b/peppol-commons/src/test/java/com/helger/peppol/smp/ESMPTransportProfileTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2015-2023 Philip Helger + * philip[at]helger[dot]com + * + * 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 com.helger.peppol.smp; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +import com.helger.commons.string.StringHelper; + +/** + * Test class for class {@link ESMPTransportProfile}. + * + * @author Philip Helger + */ +public final class ESMPTransportProfileTest +{ + @SuppressWarnings ("deprecation") + @Test + public void testBasic () + { + for (final ESMPTransportProfile e : ESMPTransportProfile.values ()) + { + assertTrue (StringHelper.hasText (e.getID ())); + assertSame (e, ESMPTransportProfile.getFromIDOrNull (e.getID ())); + } + assertSame (ESMPTransportProfileState.ACTIVE, ESMPTransportProfile.TRANSPORT_PROFILE_PEPPOL_AS4_V2.getState ()); + assertFalse (ESMPTransportProfile.TRANSPORT_PROFILE_PEPPOL_AS4_V2.isDeprecated ()); + + assertSame (ESMPTransportProfileState.DEPRECATED, ESMPTransportProfile.TRANSPORT_PROFILE_AS4.getState ()); + assertTrue (ESMPTransportProfile.TRANSPORT_PROFILE_AS4.isDeprecated ()); + } +} diff --git a/peppol-commons/src/test/java/com/helger/peppol/smp/SMPTransportProfileTest.java b/peppol-commons/src/test/java/com/helger/peppol/smp/SMPTransportProfileTest.java index 3fedf881..f1c72fe3 100644 --- a/peppol-commons/src/test/java/com/helger/peppol/smp/SMPTransportProfileTest.java +++ b/peppol-commons/src/test/java/com/helger/peppol/smp/SMPTransportProfileTest.java @@ -39,7 +39,8 @@ public void testBasic () assertEquals ("id", aTP.getID ()); assertEquals ("name", aTP.getName ()); CommonsTestHelper.testDefaultImplementationWithEqualContentObject (aTP, new SMPTransportProfile ("id", "name")); - CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (aTP, new SMPTransportProfile ("id2", "name")); + CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (aTP, + new SMPTransportProfile ("id2", "name")); CommonsTestHelper.testDefaultSerialization (aTP); XMLTestHelper.testMicroTypeConversion (aTP);