Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert BPConstraintGeneratorTest main into a test
Browse files Browse the repository at this point in the history
Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
lmsurpre committed Jun 13, 2022
1 parent 3e6c4b6 commit 758a42f
Showing 1 changed file with 10 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -7,12 +7,9 @@
package com.ibm.fhir.profile.test;

import java.util.List;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;

import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.ibm.fhir.model.annotation.Constraint;
import com.ibm.fhir.model.resource.StructureDefinition;
@@ -21,34 +18,23 @@
import com.ibm.fhir.registry.FHIRRegistry;

public class BPConstraintGeneratorTest {
private static final boolean DEBUG = true;

@BeforeClass
public void before() {
FHIRRegistry.getInstance();
FHIRRegistry.init();
}

public static void main(String[] args) throws Exception {
Logger logger = Logger.getLogger(ConstraintGenerator.class.getName());
logger.setLevel(Level.FINEST);
Handler handler = new Handler() {
@Override
public void publish(LogRecord record) {
System.out.println(record.getMessage());
}

@Override
public void flush() {
System.out.flush();
}

@Override
public void close() throws SecurityException { }
};
handler.setLevel(Level.FINEST);
logger.addHandler(handler);
@Test
public void generateConstraints() throws Exception {
StructureDefinition profile = ProfileSupport.getProfile("http://hl7.org/fhir/StructureDefinition/bp");
ConstraintGenerator generator = new ConstraintGenerator(profile);
List<Constraint> constraints = generator.generate();
constraints.forEach(System.out::println);
for (Constraint constraint : constraints) {
if (DEBUG) {
System.out.println(constraint.id() + "\t" + constraint.expression());
}
}
}
}

0 comments on commit 758a42f

Please sign in to comment.