Skip to content

Commit 95f29bc

Browse files
authored
Merge pull request #503 from gregjotau/fix/endpoint-count
Count all endpoints in SMPProcess
2 parents b3f6228 + 6c239fd commit 95f29bc

2 files changed

Lines changed: 60 additions & 1 deletion

File tree

phoss-smp-backend/src/main/java/com/helger/phoss/smp/domain/serviceinfo/SMPProcess.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ public final void setProcessIdentifier (@NonNull final IProcessIdentifier aProce
7070
@Nonnegative
7171
public int getEndpointCount ()
7272
{
73-
return m_aEndpoints.size ();
73+
int ret = 0;
74+
for (final var aEndpoints : m_aEndpoints.values ())
75+
ret += aEndpoints.size ();
76+
return ret;
7477
}
7578

7679
@Nullable
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (C) 2015-2026 Philip Helger and contributors
3+
* philip[at]helger[dot]com
4+
*
5+
* The Original Code is Copyright The Peppol project (http://www.peppol.eu)
6+
*
7+
* This Source Code Form is subject to the terms of the Mozilla Public
8+
* License, v. 2.0. If a copy of the MPL was not distributed with this
9+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
10+
*/
11+
package com.helger.phoss.smp.domain.serviceinfo;
12+
13+
import static org.junit.Assert.assertEquals;
14+
15+
import org.junit.Test;
16+
17+
import com.helger.peppolid.peppol.PeppolIdentifierHelper;
18+
import com.helger.peppolid.simple.process.SimpleProcessIdentifier;
19+
20+
/**
21+
* Test class for {@link SMPProcess#getEndpointCount()}.
22+
*
23+
* @author Greg Taube
24+
*/
25+
public final class SMPProcessEndpointCountTest
26+
{
27+
private static SMPEndpoint _createEndpoint (final String sID, final String sTransportProfile)
28+
{
29+
return new SMPEndpoint (sID,
30+
sTransportProfile,
31+
"http://localhost/as2",
32+
false,
33+
null,
34+
null,
35+
null,
36+
"cert",
37+
"description",
38+
"https://example.org/contact",
39+
null,
40+
null);
41+
}
42+
43+
@Test
44+
public void testMultipleEndpointsPerTransportProfile ()
45+
{
46+
final SMPProcess aProcess = new SMPProcess (new SimpleProcessIdentifier (PeppolIdentifierHelper.DEFAULT_PROCESS_SCHEME,
47+
"test-process"),
48+
null,
49+
null);
50+
aProcess.addEndpoint (_createEndpoint ("endpoint-1", "transport-profile-1"));
51+
aProcess.addEndpoint (_createEndpoint ("endpoint-2", "transport-profile-1"));
52+
aProcess.addEndpoint (_createEndpoint ("endpoint-3", "transport-profile-2"));
53+
54+
assertEquals (3, aProcess.getEndpointCount ());
55+
}
56+
}

0 commit comments

Comments
 (0)