Skip to content

Commit c269d21

Browse files
authored
convert BPConstraintGeneratorTest main into a test (#3705)
* convert BPConstraintGeneratorTest main into a test Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com> * address feedback Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
1 parent b6043f3 commit c269d21

1 file changed

Lines changed: 14 additions & 25 deletions

File tree

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
/*
2-
* (C) Copyright IBM Corp. 2021
2+
* (C) Copyright IBM Corp. 2021, 2022
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

77
package com.ibm.fhir.profile.test;
88

9+
import static org.testng.Assert.assertEquals;
10+
911
import java.util.List;
10-
import java.util.logging.Handler;
11-
import java.util.logging.Level;
12-
import java.util.logging.LogRecord;
13-
import java.util.logging.Logger;
1412

1513
import org.testng.annotations.BeforeClass;
14+
import org.testng.annotations.Test;
1615

1716
import com.ibm.fhir.model.annotation.Constraint;
1817
import com.ibm.fhir.model.resource.StructureDefinition;
@@ -21,34 +20,24 @@
2120
import com.ibm.fhir.registry.FHIRRegistry;
2221

2322
public class BPConstraintGeneratorTest {
23+
private static final boolean DEBUG = false;
24+
2425
@BeforeClass
2526
public void before() {
2627
FHIRRegistry.getInstance();
2728
FHIRRegistry.init();
2829
}
2930

30-
public static void main(String[] args) throws Exception {
31-
Logger logger = Logger.getLogger(ConstraintGenerator.class.getName());
32-
logger.setLevel(Level.FINEST);
33-
Handler handler = new Handler() {
34-
@Override
35-
public void publish(LogRecord record) {
36-
System.out.println(record.getMessage());
37-
}
38-
39-
@Override
40-
public void flush() {
41-
System.out.flush();
42-
}
43-
44-
@Override
45-
public void close() throws SecurityException { }
46-
};
47-
handler.setLevel(Level.FINEST);
48-
logger.addHandler(handler);
31+
@Test
32+
public void generateConstraints() throws Exception {
4933
StructureDefinition profile = ProfileSupport.getProfile("http://hl7.org/fhir/StructureDefinition/bp");
5034
ConstraintGenerator generator = new ConstraintGenerator(profile);
5135
List<Constraint> constraints = generator.generate();
52-
constraints.forEach(System.out::println);
36+
assertEquals(constraints.size(), 9);
37+
for (Constraint constraint : constraints) {
38+
if (DEBUG) {
39+
System.out.println(constraint.id() + "\t" + constraint.expression());
40+
}
41+
}
5342
}
5443
}

0 commit comments

Comments
 (0)