Migrate to JUnit5 (#1952)
* Work on junit * Work on junit 5 * Work on junit 5 * Bump errorprone vcersion * Work on tests * Junit 5 tweaks * Fixes * Work on tests * Work on junit5 * Work on tests * Test fixes * Work on junit5 * Test work * Get junit5 working * Test fix * Work on tests * WOrk on tests * Work on tests * fixes * Compile fix * One more tweak * Compile fix * Add changelog * Fix compile error * Compile fix
This commit is contained in:
parent
290577ff3e
commit
f356c7c385
|
@ -2,7 +2,7 @@
|
|||
|
||||
Most of the projects in this module are no longer supported.
|
||||
|
||||
The test in hapi-fhir-jpaserver-cds-example is @Ignored until Chris Schuler is able to make a change to the pom
|
||||
The test in hapi-fhir-jpaserver-cds-example is @Disabledd until Chris Schuler is able to make a change to the pom
|
||||
this module depends on.
|
||||
|
||||
## Supported JPA Example:
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.eclipse.jetty.server.Server;
|
|||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.hl7.fhir.dstu3.model.*;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.junit.*;
|
||||
import org.junit.jupiter.api.*; import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
|
@ -21,8 +21,8 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
// TODO Remove @Ignore once Chris Schuler has fixed the external jar this project depends on
|
||||
@Ignore
|
||||
// TODO Remove @Disabled once Chris Schuler has fixed the external jar this project depends on
|
||||
@Disabled
|
||||
public class CdsExampleTests {
|
||||
private static IGenericClient ourClient;
|
||||
private static FhirContext ourCtx = FhirContext.forDstu3();
|
||||
|
@ -34,7 +34,7 @@ public class CdsExampleTests {
|
|||
|
||||
private static Collection<IResourceProvider> providers;
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void beforeClass() throws Exception {
|
||||
|
||||
// Configure and spin up server
|
||||
|
@ -67,7 +67,7 @@ public class CdsExampleTests {
|
|||
putResource("general-fhirhelpers-3.json", "FHIRHelpers");
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@AfterAll
|
||||
public static void afterClass() throws Exception {
|
||||
JettyUtil.closeServer(ourServer);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package ca.uhn.fhir.jpa.demo;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -10,10 +10,10 @@ import java.util.List;
|
|||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeEachClass;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
|
@ -35,7 +35,7 @@ public class ExampleServerIT {
|
|||
private static String ourServerBase;
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void testCreateAndRead() throws IOException {
|
||||
ourLog.info("Base URL is: http://localhost:" + ourPort + "/baseDstu2");
|
||||
String methodName = "testCreateResourceConditional";
|
||||
|
@ -50,12 +50,12 @@ public class ExampleServerIT {
|
|||
assertEquals(famNames, pt2.getName().get(0).getFamily());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@AfterAll
|
||||
public static void afterClass() throws Exception {
|
||||
JettyUtil.closeServer(ourServer);
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void beforeClass() throws Exception {
|
||||
/*
|
||||
* This runs under maven, and I'm not sure how else to figure out the target directory from code..
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package ca.uhn.fhir.android;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
@ -10,8 +10,9 @@ import java.util.zip.ZipFile;
|
|||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.dstu2.composite.QuantityDt;
|
||||
|
@ -22,7 +23,7 @@ import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException;
|
|||
public class BuiltJarDstu2IT {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BuiltJarDstu2IT.class);
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void beforeClass() {
|
||||
System.setProperty("javax.xml.stream.XMLInputFactory", "FOO");
|
||||
System.setProperty("javax.xml.stream.XMLOutputFactory", "FOO");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package ca.uhn.fhir.android;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
@ -9,8 +9,8 @@ import java.util.zip.ZipFile;
|
|||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.dstu2.composite.QuantityDt;
|
||||
|
@ -22,7 +22,7 @@ public class BuiltJarDstu2ShadeIT {
|
|||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BuiltJarDstu2ShadeIT.class);
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void testParserXml() throws Exception {
|
||||
|
||||
FhirContext ctx = FhirContext.forDstu2();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package ca.uhn.fhir.android.client;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
@ -10,7 +10,7 @@ import java.util.Date;
|
|||
|
||||
import ca.uhn.fhir.rest.api.PreferReturnEnum;
|
||||
import org.hl7.fhir.dstu3.model.*;
|
||||
import org.junit.*;
|
||||
import org.junit.jupiter.api.*; import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
|
@ -41,7 +41,7 @@ public class GenericClientDstu3IT {
|
|||
private Request myRequest;
|
||||
private Protocol myProtocol;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void before() throws IOException {
|
||||
myHttpClient = mock(Call.Factory.class, Mockito.RETURNS_DEEP_STUBS);
|
||||
ourCtx.getRestfulClientFactory().setHttpClient(myHttpClient);
|
||||
|
@ -82,7 +82,7 @@ public class GenericClientDstu3IT {
|
|||
* TODO: narratives don't work without stax
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void testBinaryCreateWithFhirContentType() throws Exception {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
|
@ -733,7 +733,7 @@ public class GenericClientDstu3IT {
|
|||
|
||||
//TODO: narratives don't work without stax
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void testUpdateById() throws Exception {
|
||||
IParser p = ourCtx.newJsonParser();
|
||||
|
||||
|
@ -773,7 +773,7 @@ public class GenericClientDstu3IT {
|
|||
|
||||
// TODO: narratives don't work without stax
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void testUpdateWithPreferRepresentationServerReturnsOO() throws Exception {
|
||||
final IParser p = ourCtx.newJsonParser();
|
||||
|
||||
|
@ -897,7 +897,7 @@ public class GenericClientDstu3IT {
|
|||
|
||||
// TODO: narratives don't work without stax
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void testValidate() throws Exception {
|
||||
final IParser p = ourCtx.newXmlParser();
|
||||
|
||||
|
@ -938,12 +938,12 @@ public class GenericClientDstu3IT {
|
|||
*/
|
||||
|
||||
|
||||
@AfterClass
|
||||
@AfterAll
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void beforeClass() {
|
||||
|
||||
// // Force StAX to fail like it will on android
|
||||
|
|
|
@ -41,6 +41,7 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -94,6 +95,7 @@ import java.util.Set;
|
|||
public class FhirContext {
|
||||
|
||||
private static final List<Class<? extends IBaseResource>> EMPTY_LIST = Collections.emptyList();
|
||||
private static final Map<FhirVersionEnum, FhirContext> ourStaticContexts = Collections.synchronizedMap(new EnumMap<>(FhirVersionEnum.class));
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirContext.class);
|
||||
private final IFhirVersion myVersion;
|
||||
private AddProfileTagEnum myAddProfileTagWhenEncoding = AddProfileTagEnum.ONLY_FOR_CUSTOM;
|
||||
|
@ -465,6 +467,7 @@ public class FhirContext {
|
|||
|
||||
/**
|
||||
* Returns the name of a given resource class.
|
||||
*
|
||||
* @param theResourceType
|
||||
* @return
|
||||
*/
|
||||
|
@ -1034,6 +1037,17 @@ public class FhirContext {
|
|||
return new FhirContext(FhirVersionEnum.R5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a statically cached {@literal FhirContext} instance for the given version, creating one if none exists in the
|
||||
* cache. One FhirContext will be kept in the cache for each FHIR version that is requested (by calling
|
||||
* this method for that version), and the cache will never be expired.
|
||||
*
|
||||
* @since 5.1.0
|
||||
*/
|
||||
public static FhirContext forCached(FhirVersionEnum theFhirVersionEnum) {
|
||||
return ourStaticContexts.computeIfAbsent(theFhirVersionEnum, v -> new FhirContext(v));
|
||||
}
|
||||
|
||||
private static Collection<Class<? extends IBaseResource>> toCollection(Class<? extends IBaseResource> theResourceType) {
|
||||
ArrayList<Class<? extends IBaseResource>> retVal = new ArrayList<>(1);
|
||||
retVal.add(theResourceType);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package ca.uhn.fhir.context;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class FhirVersionEnumTest {
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package ca.uhn.fhir.i18n;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class HapiLocalizerTest {
|
||||
|
||||
|
|
|
@ -9,9 +9,9 @@ import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
|
|||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.util.StopWatch;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -19,8 +19,15 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
//import org.junit.jupiter.api.Disabled;
|
||||
|
||||
public class InterceptorServiceTest {
|
||||
|
||||
|
@ -121,17 +128,17 @@ public class InterceptorServiceTest {
|
|||
svc.registerInterceptor(myInterceptorManual);
|
||||
List<Object> globalInterceptors = svc.getGlobalInterceptorsForUnitTest();
|
||||
assertEquals(3, globalInterceptors.size());
|
||||
assertTrue(globalInterceptors.get(0).getClass().toString(), globalInterceptors.get(0) instanceof MyTestInterceptorOne);
|
||||
assertTrue(globalInterceptors.get(1).getClass().toString(), globalInterceptors.get(1) instanceof MyTestInterceptorManual);
|
||||
assertTrue(globalInterceptors.get(2).getClass().toString(), globalInterceptors.get(2) instanceof MyTestInterceptorTwo);
|
||||
assertTrue(globalInterceptors.get(0) instanceof MyTestInterceptorOne, globalInterceptors.get(0).getClass().toString());
|
||||
assertTrue(globalInterceptors.get(1) instanceof MyTestInterceptorManual, globalInterceptors.get(1).getClass().toString());
|
||||
assertTrue(globalInterceptors.get(2) instanceof MyTestInterceptorTwo, globalInterceptors.get(2).getClass().toString());
|
||||
|
||||
// Try to register again (should have no effect
|
||||
svc.registerInterceptor(myInterceptorManual);
|
||||
globalInterceptors = svc.getGlobalInterceptorsForUnitTest();
|
||||
assertEquals(3, globalInterceptors.size());
|
||||
assertTrue(globalInterceptors.get(0).getClass().toString(), globalInterceptors.get(0) instanceof MyTestInterceptorOne);
|
||||
assertTrue(globalInterceptors.get(1).getClass().toString(), globalInterceptors.get(1) instanceof MyTestInterceptorManual);
|
||||
assertTrue(globalInterceptors.get(2).getClass().toString(), globalInterceptors.get(2) instanceof MyTestInterceptorTwo);
|
||||
assertTrue(globalInterceptors.get(0) instanceof MyTestInterceptorOne, globalInterceptors.get(0).getClass().toString());
|
||||
assertTrue(globalInterceptors.get(1) instanceof MyTestInterceptorManual, globalInterceptors.get(1).getClass().toString());
|
||||
assertTrue(globalInterceptors.get(2) instanceof MyTestInterceptorTwo, globalInterceptors.get(2).getClass().toString());
|
||||
|
||||
// Make sure we have the right invokers in the right order
|
||||
List<Object> invokers = svc.getInterceptorsWithInvokersForPointcut(Pointcut.TEST_RB);
|
||||
|
@ -143,8 +150,8 @@ public class InterceptorServiceTest {
|
|||
svc.unregisterInterceptor(myInterceptorManual);
|
||||
globalInterceptors = svc.getGlobalInterceptorsForUnitTest();
|
||||
assertEquals(2, globalInterceptors.size());
|
||||
assertTrue(globalInterceptors.get(0).getClass().toString(), globalInterceptors.get(0) instanceof MyTestInterceptorOne);
|
||||
assertTrue(globalInterceptors.get(1).getClass().toString(), globalInterceptors.get(1) instanceof MyTestInterceptorTwo);
|
||||
assertTrue(globalInterceptors.get(0) instanceof MyTestInterceptorOne, globalInterceptors.get(0).getClass().toString());
|
||||
assertTrue(globalInterceptors.get(1) instanceof MyTestInterceptorTwo, globalInterceptors.get(1).getClass().toString());
|
||||
|
||||
}
|
||||
|
||||
|
@ -449,7 +456,7 @@ public class InterceptorServiceTest {
|
|||
* </pre>
|
||||
*/
|
||||
@Test
|
||||
@Ignore("Performance test - Not needed normally")
|
||||
@Disabled("Performance test - Not needed normally")
|
||||
public void testThreadLocalHookInterceptorMicroBenchmark() {
|
||||
threadLocalMicroBenchmark(true, 500000);
|
||||
threadLocalMicroBenchmark(false, 500000);
|
||||
|
@ -497,7 +504,7 @@ public class InterceptorServiceTest {
|
|||
ourLog.info("ThreadLocalEnabled={} - Performed {} loops in {} - {} / loop - Outcomne: {}", theThreadlocalInvokersEnabled, theCount, sw.toString(), sw.formatMillisPerOperation(theCount), interceptor.myCount);
|
||||
}
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void before() {
|
||||
myInvocations.clear();
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package ca.uhn.fhir.interceptor.model;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
|
||||
public class RequestPartitionIdTest {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package ca.uhn.fhir.model.api;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class ResourceMetadataKeyEnumTest {
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package ca.uhn.fhir.model.api;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TagTest {
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package ca.uhn.fhir.parser.json;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.io.StringReader;
|
||||
|
||||
import ca.uhn.fhir.parser.json.jackson.JacksonStructure;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class JsonLikeStructureTest {
|
||||
// private static FhirContext ourCtx;
|
||||
|
@ -141,4 +141,4 @@ public class JsonLikeStructureTest {
|
|||
assertEquals(value.getAsString(), "true");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package ca.uhn.fhir.rest.api;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class CacheControlDirectiveTest {
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package ca.uhn.fhir.rest.api;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ConstantsTest {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package ca.uhn.fhir.rest.api;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class EncodingEnumTest {
|
||||
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
package ca.uhn.fhir.rest.api;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.rest.api.QualifiedParamList;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class QualifiedParamListTest {
|
||||
|
||||
|
@ -37,7 +35,7 @@ public class QualifiedParamListTest {
|
|||
}
|
||||
|
||||
|
||||
@AfterClass
|
||||
@AfterAll
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
|
|
@ -2,22 +2,19 @@ package ca.uhn.fhir.rest.param;
|
|||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.rest.api.QualifiedParamList;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@RunWith(JUnit4.class)
|
||||
public class DateRangeParamTest {
|
||||
private FhirContext fhirContext;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void initMockContext() {
|
||||
fhirContext = Mockito.mock(FhirContext.class);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package ca.uhn.fhir.rest.param;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class QualifierDetailsTest {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package ca.uhn.fhir.rest.param;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class StringParamTest {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package ca.uhn.fhir.rest.param;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TokenParamTest {
|
||||
@Test
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package ca.uhn.fhir.rest.server.exceptions;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class BaseServerResponseExceptionTest {
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package ca.uhn.fhir.util;
|
||||
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package ca.uhn.fhir.util;
|
||||
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package ca.uhn.fhir.util;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.util.jar.DependencyLogFactory;
|
||||
import ca.uhn.fhir.util.jar.IDependencyLog;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
public class DependencyLogUtilTest {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package ca.uhn.fhir.util;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class FileUtilTest {
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package ca.uhn.fhir.util;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.event.Level;
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package ca.uhn.fhir.util;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ObjectUtilTest {
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package ca.uhn.fhir.util;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
|
||||
|
|
|
@ -2,21 +2,21 @@ package ca.uhn.fhir.util;
|
|||
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class StopWatchTest {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(StopWatchTest.class);
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void after() {
|
||||
StopWatch.setNowForUnitTestForUnitTest(null);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package ca.uhn.fhir.util;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class UrlUtilTest {
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package ca.uhn.fhir.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package ca.uhn.fhir.util;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.hasItem;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
public class VersionEnumTest {
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package ca.uhn.fhir.util;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.blankOrNullString;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class VersionUtilTest {
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package ca.uhn.fhir.validation;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class PlaceholderTest {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package ca.uhn.fhir.validation;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ResultSeverityEnumTest {
|
||||
|
||||
|
|
|
@ -3,12 +3,12 @@ package ca.uhn.fhir.cli;
|
|||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class BaseCommandTest {
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
|
|||
import org.hl7.fhir.r4.model.StructureDefinition;
|
||||
import org.hl7.fhir.r4.model.ValueSet;
|
||||
import org.hl7.fhir.utilities.cache.NpmPackage;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.rauschig.jarchivelib.Archiver;
|
||||
import org.rauschig.jarchivelib.ArchiverFactory;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -27,7 +27,7 @@ import java.io.IOException;
|
|||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class CreatePackageCommandTest extends BaseTest {
|
||||
|
||||
|
@ -41,14 +41,14 @@ public class CreatePackageCommandTest extends BaseTest {
|
|||
System.setProperty("test", "true");
|
||||
}
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void start() {
|
||||
myWorkDirectory = Files.createTempDir();
|
||||
myTargetDirectory = Files.createTempDir();
|
||||
myExtractDirectory = Files.createTempDir();
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void stop() {
|
||||
try {
|
||||
FileUtils.deleteDirectory(myWorkDirectory);
|
||||
|
|
|
@ -5,7 +5,7 @@ import ca.uhn.fhir.rest.client.api.IGenericClient;
|
|||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.rest.server.interceptor.VerboseLoggingInterceptor;
|
||||
import ca.uhn.fhir.test.utilities.JettyUtil;
|
||||
import ca.uhn.fhir.test.utilities.LoggingRule;
|
||||
import ca.uhn.fhir.test.utilities.LoggingExtension;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import com.google.common.base.Charsets;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
@ -16,17 +16,17 @@ import org.eclipse.jetty.servlet.ServletHolder;
|
|||
import org.hl7.fhir.dstu3.model.ConceptMap;
|
||||
import org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence;
|
||||
import org.hl7.fhir.dstu3.model.UriType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.awaitility.Awaitility.await;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class ExportConceptMapToCsvCommandDstu3Test {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExportConceptMapToCsvCommandDstu3Test.class);
|
||||
|
@ -49,8 +49,8 @@ public class ExportConceptMapToCsvCommandDstu3Test {
|
|||
System.setProperty("test", "true");
|
||||
}
|
||||
|
||||
@Rule
|
||||
public LoggingRule myLoggingRule = new LoggingRule();
|
||||
@RegisterExtension
|
||||
public LoggingExtension myLoggingExtension = new LoggingExtension();
|
||||
|
||||
@Test
|
||||
public void testExportConceptMapToCsvCommand() throws IOException {
|
||||
|
@ -85,13 +85,13 @@ public class ExportConceptMapToCsvCommandDstu3Test {
|
|||
FileUtils.deleteQuietly(new File(FILE));
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@AfterAll
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
JettyUtil.closeServer(ourServer);
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void beforeClass() throws Exception {
|
||||
ourServer = new Server(0);
|
||||
|
||||
|
|
|
@ -15,16 +15,16 @@ import org.eclipse.jetty.servlet.ServletHolder;
|
|||
import org.hl7.fhir.r4.model.ConceptMap;
|
||||
import org.hl7.fhir.r4.model.Enumerations.ConceptMapEquivalence;
|
||||
import org.hl7.fhir.r4.model.UriType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.awaitility.Awaitility.await;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class ExportConceptMapToCsvCommandR4Test {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExportConceptMapToCsvCommandR4Test.class);
|
||||
|
@ -78,13 +78,13 @@ public class ExportConceptMapToCsvCommandR4Test {
|
|||
FileUtils.deleteQuietly(new File(FILE));
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@AfterAll
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
JettyUtil.closeServer(ourServer);
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void beforeClass() throws Exception {
|
||||
ourServer = new Server(0);
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import ca.uhn.fhir.jpa.migrate.JdbcUtils;
|
|||
import com.google.common.base.Charsets;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
@ -26,9 +26,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class HapiFlywayMigrateDatabaseCommandTest {
|
||||
|
||||
|
|
|
@ -5,27 +5,27 @@ import ca.uhn.fhir.rest.api.MethodOutcome;
|
|||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.rest.server.interceptor.VerboseLoggingInterceptor;
|
||||
import ca.uhn.fhir.test.utilities.JettyUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.ServletHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.dstu3.model.Bundle;
|
||||
import org.hl7.fhir.dstu3.model.ConceptMap;
|
||||
import org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent;
|
||||
import org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent;
|
||||
import org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent;
|
||||
import org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import ca.uhn.fhir.test.utilities.JettyUtil;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
public class ImportCsvToConceptMapCommandDstu3Test {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ImportCsvToConceptMapCommandDstu3Test.class);
|
||||
|
@ -53,40 +53,12 @@ public class ImportCsvToConceptMapCommandDstu3Test {
|
|||
System.setProperty("test", "true");
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void afterClearResourceProvider() {
|
||||
HashMapResourceProviderConceptMapDstu3 resourceProvider = (HashMapResourceProviderConceptMapDstu3) restfulServer.getResourceProviders().iterator().next();
|
||||
resourceProvider.clear();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
JettyUtil.closeServer(ourServer);
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
ourServer = new Server(0);
|
||||
|
||||
ServletHandler servletHandler = new ServletHandler();
|
||||
|
||||
restfulServer = new RestfulServer(ourCtx);
|
||||
restfulServer.registerInterceptor(new VerboseLoggingInterceptor());
|
||||
restfulServer.setResourceProviders(new HashMapResourceProviderConceptMapDstu3(ourCtx));
|
||||
|
||||
ServletHolder servletHolder = new ServletHolder(restfulServer);
|
||||
servletHandler.addServletWithMapping(servletHolder, "/*");
|
||||
ourServer.setHandler(servletHandler);
|
||||
|
||||
JettyUtil.startServer(ourServer);
|
||||
ourPort = JettyUtil.getPortForStartedServer(ourServer);
|
||||
|
||||
ourBase = "http://localhost:" + ourPort;
|
||||
|
||||
ourClient = ourCtx.newRestfulGenericClient(ourBase);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConditionalUpdateResultsInCreate() {
|
||||
ConceptMap conceptMap = ExportConceptMapToCsvCommandDstu3Test.createConceptMap();
|
||||
|
@ -149,7 +121,7 @@ public class ImportCsvToConceptMapCommandDstu3Test {
|
|||
File fileToImport = new File(classLoader.getResource(FILENAME).getFile());
|
||||
ImportCsvToConceptMapCommandDstu3Test.file = fileToImport.getAbsolutePath();
|
||||
|
||||
App.main(new String[] {"import-csv-to-conceptmap",
|
||||
App.main(new String[]{"import-csv-to-conceptmap",
|
||||
"-v", ourVersion,
|
||||
"-t", ourBase,
|
||||
"-u", CM_URL,
|
||||
|
@ -345,7 +317,7 @@ public class ImportCsvToConceptMapCommandDstu3Test {
|
|||
assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
|
||||
assertEquals("3d This is a comment.", target.getComment());
|
||||
|
||||
App.main(new String[] {"import-csv-to-conceptmap",
|
||||
App.main(new String[]{"import-csv-to-conceptmap",
|
||||
"-v", ourVersion,
|
||||
"-t", ourBase,
|
||||
"-u", CM_URL,
|
||||
|
@ -365,4 +337,32 @@ public class ImportCsvToConceptMapCommandDstu3Test {
|
|||
|
||||
assertEquals("http://localhost:" + ourPort + "/ConceptMap/1/_history/2", conceptMap.getId());
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
JettyUtil.closeServer(ourServer);
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeClass() throws Exception {
|
||||
ourServer = new Server(0);
|
||||
|
||||
ServletHandler servletHandler = new ServletHandler();
|
||||
|
||||
restfulServer = new RestfulServer(ourCtx);
|
||||
restfulServer.registerInterceptor(new VerboseLoggingInterceptor());
|
||||
restfulServer.setResourceProviders(new HashMapResourceProviderConceptMapDstu3(ourCtx));
|
||||
|
||||
ServletHolder servletHolder = new ServletHolder(restfulServer);
|
||||
servletHandler.addServletWithMapping(servletHolder, "/*");
|
||||
ourServer.setHandler(servletHandler);
|
||||
|
||||
JettyUtil.startServer(ourServer);
|
||||
ourPort = JettyUtil.getPortForStartedServer(ourServer);
|
||||
|
||||
ourBase = "http://localhost:" + ourPort;
|
||||
|
||||
ourClient = ourCtx.newRestfulGenericClient(ourBase);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,27 +5,28 @@ import ca.uhn.fhir.rest.api.MethodOutcome;
|
|||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.rest.server.interceptor.VerboseLoggingInterceptor;
|
||||
import ca.uhn.fhir.test.utilities.JettyUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.ServletHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.r4.model.Bundle;
|
||||
import org.hl7.fhir.r4.model.ConceptMap;
|
||||
import org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupComponent;
|
||||
import org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent;
|
||||
import org.hl7.fhir.r4.model.ConceptMap.TargetElementComponent;
|
||||
import org.hl7.fhir.r4.model.Enumerations.ConceptMapEquivalence;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import ca.uhn.fhir.test.utilities.JettyUtil;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class ImportCsvToConceptMapCommandR4Test {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ImportCsvToConceptMapCommandR4Test.class);
|
||||
|
@ -53,40 +54,12 @@ public class ImportCsvToConceptMapCommandR4Test {
|
|||
System.setProperty("test", "true");
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void afterClearResourceProvider() {
|
||||
HashMapResourceProviderConceptMapR4 resourceProvider = (HashMapResourceProviderConceptMapR4) restfulServer.getResourceProviders().iterator().next();
|
||||
resourceProvider.clear();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
JettyUtil.closeServer(ourServer);
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
ourServer = new Server(0);
|
||||
|
||||
ServletHandler servletHandler = new ServletHandler();
|
||||
|
||||
restfulServer = new RestfulServer(ourCtx);
|
||||
restfulServer.registerInterceptor(new VerboseLoggingInterceptor());
|
||||
restfulServer.setResourceProviders(new HashMapResourceProviderConceptMapR4(ourCtx));
|
||||
|
||||
ServletHolder servletHolder = new ServletHolder(restfulServer);
|
||||
servletHandler.addServletWithMapping(servletHolder, "/*");
|
||||
ourServer.setHandler(servletHandler);
|
||||
|
||||
JettyUtil.startServer(ourServer);
|
||||
ourPort = JettyUtil.getPortForStartedServer(ourServer);
|
||||
|
||||
ourBase = "http://localhost:" + ourPort;
|
||||
|
||||
ourClient = ourCtx.newRestfulGenericClient(ourBase);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConditionalUpdateResultsInCreate() {
|
||||
ConceptMap conceptMap = ExportConceptMapToCsvCommandR4Test.createConceptMap();
|
||||
|
@ -154,7 +127,7 @@ public class ImportCsvToConceptMapCommandR4Test {
|
|||
File fileToImport = new File(classLoader.getResource(FILENAME).getFile());
|
||||
ImportCsvToConceptMapCommandR4Test.file = fileToImport.getAbsolutePath();
|
||||
|
||||
App.main(new String[] {"import-csv-to-conceptmap",
|
||||
App.main(new String[]{"import-csv-to-conceptmap",
|
||||
"-v", ourVersion,
|
||||
"-t", ourBase,
|
||||
"-u", CM_URL,
|
||||
|
@ -350,7 +323,7 @@ public class ImportCsvToConceptMapCommandR4Test {
|
|||
assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
|
||||
assertEquals("3d This is a comment.", target.getComment());
|
||||
|
||||
App.main(new String[] {"import-csv-to-conceptmap",
|
||||
App.main(new String[]{"import-csv-to-conceptmap",
|
||||
"-v", ourVersion,
|
||||
"-t", ourBase,
|
||||
"-u", CM_URL,
|
||||
|
@ -377,7 +350,7 @@ public class ImportCsvToConceptMapCommandR4Test {
|
|||
File fileToImport = new File(classLoader.getResource("loinc-to-phenx.csv").getFile());
|
||||
ImportCsvToConceptMapCommandR4Test.file = fileToImport.getAbsolutePath();
|
||||
|
||||
App.main(new String[] {"import-csv-to-conceptmap",
|
||||
App.main(new String[]{"import-csv-to-conceptmap",
|
||||
"-v", ourVersion,
|
||||
"-t", ourBase,
|
||||
"-u", "http://loinc.org/cm/loinc-to-phenx",
|
||||
|
@ -425,7 +398,7 @@ public class ImportCsvToConceptMapCommandR4Test {
|
|||
assertEquals(ConceptMapEquivalence.EQUIVALENT, target.getEquivalence());
|
||||
assertNull(target.getComment());
|
||||
|
||||
App.main(new String[] {"import-csv-to-conceptmap",
|
||||
App.main(new String[]{"import-csv-to-conceptmap",
|
||||
"-v", ourVersion,
|
||||
"-t", ourBase,
|
||||
"-u", "http://loinc.org/cm/loinc-to-phenx",
|
||||
|
@ -445,4 +418,32 @@ public class ImportCsvToConceptMapCommandR4Test {
|
|||
|
||||
assertEquals("http://localhost:" + ourPort + "/ConceptMap/1/_history/2", conceptMap.getId());
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
JettyUtil.closeServer(ourServer);
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeClass() throws Exception {
|
||||
ourServer = new Server(0);
|
||||
|
||||
ServletHandler servletHandler = new ServletHandler();
|
||||
|
||||
restfulServer = new RestfulServer(ourCtx);
|
||||
restfulServer.registerInterceptor(new VerboseLoggingInterceptor());
|
||||
restfulServer.setResourceProviders(new HashMapResourceProviderConceptMapR4(ourCtx));
|
||||
|
||||
ServletHolder servletHolder = new ServletHolder(restfulServer);
|
||||
servletHandler.addServletWithMapping(servletHolder, "/*");
|
||||
ourServer.setHandler(servletHandler);
|
||||
|
||||
JettyUtil.startServer(ourServer);
|
||||
ourPort = JettyUtil.getPortForStartedServer(ourServer);
|
||||
|
||||
ourBase = "http://localhost:" + ourPort;
|
||||
|
||||
ourClient = ourCtx.newRestfulGenericClient(ourBase);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package ca.uhn.fhir.cli;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class InstallIgPackTest {
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package ca.uhn.fhir.cli;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class OptionsTest {
|
||||
|
||||
|
|
|
@ -17,14 +17,14 @@ import org.hamcrest.Matchers;
|
|||
import org.hl7.fhir.r4.model.CodeSystem;
|
||||
import org.hl7.fhir.r4.model.IdType;
|
||||
import org.hl7.fhir.r4.model.Patient;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.List;
|
||||
|
@ -32,14 +32,15 @@ import java.util.zip.ZipEntry;
|
|||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.matchesPattern;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class UploadTerminologyCommandTest extends BaseTest {
|
||||
|
||||
static {
|
||||
|
@ -364,7 +365,7 @@ public class UploadTerminologyCommandTest extends BaseTest {
|
|||
}
|
||||
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void after() throws Exception {
|
||||
JettyUtil.closeServer(myServer);
|
||||
|
||||
|
@ -378,7 +379,7 @@ public class UploadTerminologyCommandTest extends BaseTest {
|
|||
UploadTerminologyCommand.setTransferSizeLimitForUnitTest(-1);
|
||||
}
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void before() throws Exception {
|
||||
myServer = new Server(0);
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package ca.uhn.fhir.cli;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
public class ValidateCommandTest {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ValidateCommandTest.class);
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void before() {
|
||||
System.setProperty("test", "true");
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class ValidateCommandTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void testValidateUsingIgPackSucceedingDstu2() {
|
||||
String resourcePath = ValidateCommandTest.class.getResource("/argo-dstu2-observation-good.json").getFile();
|
||||
ourLog.info(resourcePath);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -3,18 +3,18 @@ package ca.uhn.fhir.okhttp;
|
|||
import ca.uhn.fhir.okhttp.client.OkHttpRestfulClientFactory;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class OkHttpRestfulClientFactoryTest {
|
||||
|
||||
private OkHttpRestfulClientFactory clientFactory;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
clientFactory = new OkHttpRestfulClientFactory();
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package ca.uhn.fhir.okhttp.client;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
public class OkHttpRestfulClientTest {
|
||||
|
||||
|
@ -21,4 +21,4 @@ public class OkHttpRestfulClientTest {
|
|||
assertThat(headerBuilder.toString(), equalTo("http://example.com"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package ca.uhn.fhir.rest.client.apache;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package ca.uhn.fhir.rest.client.interceptor;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class SimpleRequestHeaderInterceptorTest {
|
||||
@Test
|
||||
|
|
|
@ -5,6 +5,7 @@ import ca.uhn.fhir.rest.annotation.Search;
|
|||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.test.utilities.JettyUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import ca.uhn.fhir.util.UrlUtil;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
@ -19,9 +20,9 @@ import org.eclipse.jetty.servlet.ServletHolder;
|
|||
import org.hl7.fhir.dstu3.model.HumanName;
|
||||
import org.hl7.fhir.dstu3.model.Patient;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
|
@ -31,8 +32,6 @@ import java.util.concurrent.TimeUnit;
|
|||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
import ca.uhn.fhir.test.utilities.JettyUtil;
|
||||
|
||||
public class VersionedApiConverterInterceptorR4Test {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(VersionedApiConverterInterceptorR4Test.class);
|
||||
|
@ -74,13 +73,13 @@ public class VersionedApiConverterInterceptorR4Test {
|
|||
}
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@AfterAll
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
JettyUtil.closeServer(ourServer);
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void beforeClass() throws Exception {
|
||||
ourServer = new Server(0);
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package org.hl7.fhir.converter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.hl7.fhir.convertors.VersionConvertor_10_30;
|
||||
import org.hl7.fhir.dstu3.model.*;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.dstu2.model.Resource;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package org.hl7.fhir.converter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.hl7.fhir.convertors.VersionConvertor_14_30;
|
||||
import org.hl7.fhir.dstu3.model.Questionnaire;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class VersionConvertor_14_30Test {
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
type: change
|
||||
issue: 1952
|
||||
title: HAPI FHIR has been migrated to use JUnit 5 (from JUnit 4) for unit testing. This change does not affect users of the
|
||||
library, but helps to make tests more maintainable.
|
|
@ -5,12 +5,12 @@ import ca.uhn.fhir.context.FhirContext;
|
|||
import ca.uhn.fhir.context.support.IValidationSupport;
|
||||
import ca.uhn.fhir.igpacks.parser.IgPackParserDstu3;
|
||||
import org.hl7.fhir.dstu3.model.ValueSet;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
public class IgPackParserDstu3Test {
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(IgPackParserDstu3Test.class);
|
||||
|
|
|
@ -162,7 +162,7 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencies>
|
||||
|
||||
<reporting>
|
||||
<plugins>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,8 +1,8 @@
|
|||
package ca.uhn.fhir.jaxrs.client;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -11,8 +11,9 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.hasItem;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.core.IsNot.not;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* Created by Sebastien Riviere on 31/07/2017.
|
||||
|
@ -51,7 +52,7 @@ public class JaxRsRestfulClientFactoryTest {
|
|||
assertThat(result.getConfiguration().getClasses(), hasItem(ca.uhn.fhir.jaxrs.client.MyFilter.class));
|
||||
}
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
factory = new JaxRsRestfulClientFactory(context);
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderDstu2Hl7Org
|
|||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
@ -16,7 +16,7 @@ import java.net.URI;
|
|||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class AbstractJaxRsConformanceProviderDstu2Hl7OrgTest {
|
|||
private ResteasyHttpHeaders headers;
|
||||
private MultivaluedHashMap<String, String> queryParameters;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
// uri info
|
||||
queryParameters = new MultivaluedHashMap<>();
|
||||
|
|
|
@ -6,8 +6,8 @@ import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderDstu2_1;
|
|||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
@ -16,7 +16,7 @@ import java.net.URI;
|
|||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class AbstractJaxRsConformanceProviderDstu2_1Test {
|
|||
private ResteasyHttpHeaders headers;
|
||||
private MultivaluedHashMap<String, String> queryParameters;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
// uri info
|
||||
queryParameters = new MultivaluedHashMap<>();
|
||||
|
|
|
@ -1,107 +1,107 @@
|
|||
package ca.uhn.fhir.jaxrs.server;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderDstu3;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderDstu3;
|
||||
|
||||
public class AbstractJaxRsConformanceProviderDstu3Test {
|
||||
|
||||
private static final String BASEURI = "http://basiuri";
|
||||
private static final String REQUESTURI = BASEURI + "/metadata";
|
||||
AbstractJaxRsConformanceProvider provider;
|
||||
private ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider> providers;
|
||||
private ResteasyHttpHeaders headers;
|
||||
private MultivaluedHashMap<String, String> queryParameters;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// uri info
|
||||
queryParameters = new MultivaluedHashMap<>();
|
||||
// headers
|
||||
// headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
// new MapPropertiesDelegate());
|
||||
headers = new ResteasyHttpHeaders(queryParameters);
|
||||
|
||||
|
||||
providers = new ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider>();
|
||||
provider = createConformanceProvider(providers);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConformance() throws Exception {
|
||||
providers.put(AbstractJaxRsConformanceProvider.class, provider);
|
||||
providers.put(TestJaxRsDummyPatientProviderDstu3.class, new TestJaxRsDummyPatientProviderDstu3());
|
||||
Response response = createConformanceProvider(providers).conformance();
|
||||
System.out.println(response);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConformanceUsingOptions() throws Exception {
|
||||
providers.put(AbstractJaxRsConformanceProvider.class, provider);
|
||||
providers.put(TestJaxRsDummyPatientProviderDstu3.class, new TestJaxRsDummyPatientProviderDstu3());
|
||||
Response response = createConformanceProvider(providers).conformanceUsingOptions();
|
||||
System.out.println(response);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConformanceWithMethods() throws Exception {
|
||||
providers.put(AbstractJaxRsConformanceProvider.class, provider);
|
||||
providers.put(TestJaxRsMockPatientRestProviderDstu3.class, new TestJaxRsMockPatientRestProviderDstu3());
|
||||
Response response = createConformanceProvider(providers).conformance();
|
||||
assertEquals(Constants.STATUS_HTTP_200_OK, response.getStatus());
|
||||
assertTrue(response.getEntity().toString().contains("\"type\": \"Patient\""));
|
||||
assertTrue(response.getEntity().toString().contains("\"someCustomOperation"));
|
||||
System.out.println(response);
|
||||
System.out.println(response.getEntity());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConformanceInXml() throws Exception {
|
||||
queryParameters.put(Constants.PARAM_FORMAT, Arrays.asList(Constants.CT_XML));
|
||||
providers.put(AbstractJaxRsConformanceProvider.class, provider);
|
||||
providers.put(TestJaxRsMockPatientRestProviderDstu3.class, new TestJaxRsMockPatientRestProviderDstu3());
|
||||
Response response = createConformanceProvider(providers).conformance();
|
||||
assertEquals(Constants.STATUS_HTTP_200_OK, response.getStatus());
|
||||
System.out.println(response.getEntity());
|
||||
assertTrue(response.getEntity().toString().contains(" <type value=\"Patient\"/>"));
|
||||
assertTrue(response.getEntity().toString().contains("\"someCustomOperation"));
|
||||
System.out.println(response.getEntity());
|
||||
}
|
||||
|
||||
private AbstractJaxRsConformanceProvider createConformanceProvider(final ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider> providers)
|
||||
throws Exception {
|
||||
AbstractJaxRsConformanceProvider result = new AbstractJaxRsConformanceProvider(FhirContext.forDstu3(), null, null, null) {
|
||||
@Override
|
||||
protected ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider> getProviders() {
|
||||
return providers;
|
||||
}
|
||||
};
|
||||
// mocks
|
||||
UriInfo uriInfo = mock(UriInfo.class);
|
||||
when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
|
||||
when(uriInfo.getBaseUri()).thenReturn(new URI(BASEURI));
|
||||
when(uriInfo.getRequestUri()).thenReturn(new URI(BASEURI + "/foo"));
|
||||
result.setUriInfo(uriInfo);
|
||||
result.setHeaders(headers);
|
||||
result.setUpPostConstruct();
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
package ca.uhn.fhir.jaxrs.server;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderDstu3;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderDstu3;
|
||||
|
||||
public class AbstractJaxRsConformanceProviderDstu3Test {
|
||||
|
||||
private static final String BASEURI = "http://basiuri";
|
||||
private static final String REQUESTURI = BASEURI + "/metadata";
|
||||
AbstractJaxRsConformanceProvider provider;
|
||||
private ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider> providers;
|
||||
private ResteasyHttpHeaders headers;
|
||||
private MultivaluedHashMap<String, String> queryParameters;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
// uri info
|
||||
queryParameters = new MultivaluedHashMap<>();
|
||||
// headers
|
||||
// headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
// new MapPropertiesDelegate());
|
||||
headers = new ResteasyHttpHeaders(queryParameters);
|
||||
|
||||
|
||||
providers = new ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider>();
|
||||
provider = createConformanceProvider(providers);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConformance() throws Exception {
|
||||
providers.put(AbstractJaxRsConformanceProvider.class, provider);
|
||||
providers.put(TestJaxRsDummyPatientProviderDstu3.class, new TestJaxRsDummyPatientProviderDstu3());
|
||||
Response response = createConformanceProvider(providers).conformance();
|
||||
System.out.println(response);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConformanceUsingOptions() throws Exception {
|
||||
providers.put(AbstractJaxRsConformanceProvider.class, provider);
|
||||
providers.put(TestJaxRsDummyPatientProviderDstu3.class, new TestJaxRsDummyPatientProviderDstu3());
|
||||
Response response = createConformanceProvider(providers).conformanceUsingOptions();
|
||||
System.out.println(response);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConformanceWithMethods() throws Exception {
|
||||
providers.put(AbstractJaxRsConformanceProvider.class, provider);
|
||||
providers.put(TestJaxRsMockPatientRestProviderDstu3.class, new TestJaxRsMockPatientRestProviderDstu3());
|
||||
Response response = createConformanceProvider(providers).conformance();
|
||||
assertEquals(Constants.STATUS_HTTP_200_OK, response.getStatus());
|
||||
assertTrue(response.getEntity().toString().contains("\"type\": \"Patient\""));
|
||||
assertTrue(response.getEntity().toString().contains("\"someCustomOperation"));
|
||||
System.out.println(response);
|
||||
System.out.println(response.getEntity());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConformanceInXml() throws Exception {
|
||||
queryParameters.put(Constants.PARAM_FORMAT, Arrays.asList(Constants.CT_XML));
|
||||
providers.put(AbstractJaxRsConformanceProvider.class, provider);
|
||||
providers.put(TestJaxRsMockPatientRestProviderDstu3.class, new TestJaxRsMockPatientRestProviderDstu3());
|
||||
Response response = createConformanceProvider(providers).conformance();
|
||||
assertEquals(Constants.STATUS_HTTP_200_OK, response.getStatus());
|
||||
System.out.println(response.getEntity());
|
||||
assertTrue(response.getEntity().toString().contains(" <type value=\"Patient\"/>"));
|
||||
assertTrue(response.getEntity().toString().contains("\"someCustomOperation"));
|
||||
System.out.println(response.getEntity());
|
||||
}
|
||||
|
||||
private AbstractJaxRsConformanceProvider createConformanceProvider(final ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider> providers)
|
||||
throws Exception {
|
||||
AbstractJaxRsConformanceProvider result = new AbstractJaxRsConformanceProvider(FhirContext.forDstu3(), null, null, null) {
|
||||
@Override
|
||||
protected ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider> getProviders() {
|
||||
return providers;
|
||||
}
|
||||
};
|
||||
// mocks
|
||||
UriInfo uriInfo = mock(UriInfo.class);
|
||||
when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
|
||||
when(uriInfo.getBaseUri()).thenReturn(new URI(BASEURI));
|
||||
when(uriInfo.getRequestUri()).thenReturn(new URI(BASEURI + "/foo"));
|
||||
result.setUriInfo(uriInfo);
|
||||
result.setHeaders(headers);
|
||||
result.setUpPostConstruct();
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderR4;
|
|||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
@ -16,7 +16,7 @@ import java.net.URI;
|
|||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class AbstractJaxRsConformanceProviderR4Test {
|
|||
private ResteasyHttpHeaders headers;
|
||||
private MultivaluedHashMap<String, String> queryParameters;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
// uri info
|
||||
queryParameters = new MultivaluedHashMap<>();
|
||||
|
|
|
@ -5,8 +5,8 @@ import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProvider;
|
|||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
@ -15,7 +15,7 @@ import java.net.URI;
|
|||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
@ -28,7 +28,7 @@ public class AbstractJaxRsConformanceProviderTest {
|
|||
private ResteasyHttpHeaders headers;
|
||||
private MultivaluedHashMap<String, String> queryParameters;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
// uri info
|
||||
queryParameters = new MultivaluedHashMap<>();
|
||||
|
|
|
@ -1,21 +1,5 @@
|
|||
package ca.uhn.fhir.jaxrs.server;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.ws.rs.core.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.interceptor.JaxRsResponseException;
|
||||
import ca.uhn.fhir.jaxrs.server.util.JaxRsRequest;
|
||||
import ca.uhn.fhir.jaxrs.server.util.JaxRsResponse;
|
||||
|
@ -24,62 +8,80 @@ import ca.uhn.fhir.parser.DataFormatException;
|
|||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.server.IRestfulResponse;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class AbstractJaxRsProviderTest {
|
||||
|
||||
private AbstractJaxRsProviderMock provider;
|
||||
@Mock
|
||||
private JaxRsRequest theRequest;
|
||||
private AbstractJaxRsProviderMock provider;
|
||||
@Mock
|
||||
private JaxRsRequest theRequest;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
provider = new AbstractJaxRsProviderMock();
|
||||
final IRestfulResponse response = new JaxRsResponse(theRequest);
|
||||
doReturn(provider).when(theRequest).getServer();
|
||||
doReturn(response).when(theRequest).getResponse();
|
||||
}
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
provider = new AbstractJaxRsProviderMock();
|
||||
final IRestfulResponse response = new JaxRsResponse(theRequest);
|
||||
doReturn(provider).when(theRequest).getServer();
|
||||
doReturn(response).when(theRequest).getResponse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleExceptionDataFormatException() throws IOException, URISyntaxException {
|
||||
final DataFormatException theException = new DataFormatException();
|
||||
UriInfo uriInfo = mock(UriInfo.class);
|
||||
when(uriInfo.getRequestUri()).thenReturn(new URI("http://example.com"));
|
||||
when(uriInfo.getBaseUri()).thenReturn(new URI("http://example.com"));
|
||||
when(uriInfo.getQueryParameters()).thenReturn(new MultivaluedHashMap<String, String>());
|
||||
provider.setUriInfo(uriInfo);
|
||||
final Response result = provider.handleException(theRequest, theException);
|
||||
assertNotNull(result);
|
||||
assertEquals(Constants.STATUS_HTTP_400_BAD_REQUEST, result.getStatus());
|
||||
}
|
||||
@Test
|
||||
public void testHandleExceptionDataFormatException() throws IOException, URISyntaxException {
|
||||
final DataFormatException theException = new DataFormatException();
|
||||
UriInfo uriInfo = mock(UriInfo.class);
|
||||
when(uriInfo.getRequestUri()).thenReturn(new URI("http://example.com"));
|
||||
when(uriInfo.getBaseUri()).thenReturn(new URI("http://example.com"));
|
||||
when(uriInfo.getQueryParameters()).thenReturn(new MultivaluedHashMap<String, String>());
|
||||
provider.setUriInfo(uriInfo);
|
||||
final Response result = provider.handleException(theRequest, theException);
|
||||
assertNotNull(result);
|
||||
assertEquals(Constants.STATUS_HTTP_400_BAD_REQUEST, result.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleExceptionJaxRsResponseException() throws IOException {
|
||||
final ResourceNotFoundException base = new ResourceNotFoundException(new IdDt(1L));
|
||||
final JaxRsResponseException theException = new JaxRsResponseException(base);
|
||||
final Response result = provider.handleException(theRequest, theException);
|
||||
assertNotNull(result);
|
||||
assertEquals(base.getStatusCode(), result.getStatus());
|
||||
}
|
||||
@Test
|
||||
public void testHandleExceptionJaxRsResponseException() throws IOException {
|
||||
final ResourceNotFoundException base = new ResourceNotFoundException(new IdDt(1L));
|
||||
final JaxRsResponseException theException = new JaxRsResponseException(base);
|
||||
final Response result = provider.handleException(theRequest, theException);
|
||||
assertNotNull(result);
|
||||
assertEquals(base.getStatusCode(), result.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleExceptionRuntimeException() throws IOException, URISyntaxException {
|
||||
final RuntimeException theException = new RuntimeException();
|
||||
final UriInfo mockUriInfo = mock(UriInfo.class);
|
||||
final MultivaluedMap<String, String> mockMap = mock(MultivaluedMap.class);
|
||||
when(mockUriInfo.getBaseUri()).thenReturn(new URI("http://www.test.com"));
|
||||
when(mockUriInfo.getRequestUri()).thenReturn(new URI("http://www.test.com/test"));
|
||||
when(mockUriInfo.getQueryParameters()).thenReturn(mockMap);
|
||||
@Test
|
||||
public void testHandleExceptionRuntimeException() throws IOException, URISyntaxException {
|
||||
assertFalse(provider.withStackTrace());
|
||||
|
||||
provider.setUriInfo(mockUriInfo);
|
||||
final Response result = provider.handleException(theRequest, theException);
|
||||
assertNotNull(result);
|
||||
assertEquals(Constants.STATUS_HTTP_500_INTERNAL_ERROR, result.getStatus());
|
||||
}
|
||||
final RuntimeException theException = new RuntimeException();
|
||||
final UriInfo mockUriInfo = mock(UriInfo.class);
|
||||
final MultivaluedMap<String, String> mockMap = mock(MultivaluedMap.class);
|
||||
when(mockUriInfo.getBaseUri()).thenReturn(new URI("http://www.test.com"));
|
||||
when(mockUriInfo.getRequestUri()).thenReturn(new URI("http://www.test.com/test"));
|
||||
when(mockUriInfo.getQueryParameters()).thenReturn(mockMap);
|
||||
|
||||
provider.setUriInfo(mockUriInfo);
|
||||
final Response result = provider.handleException(theRequest, theException);
|
||||
assertNotNull(result);
|
||||
assertEquals(Constants.STATUS_HTTP_500_INTERNAL_ERROR, result.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithStackTrace() {
|
||||
assertFalse(provider.withStackTrace());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,13 +7,17 @@ import ca.uhn.fhir.jaxrs.server.test.TestJaxRsConformanceRestProviderDstu3;
|
|||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPageProviderDstu3;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderDstu3;
|
||||
import ca.uhn.fhir.model.primitive.UriDt;
|
||||
import ca.uhn.fhir.rest.api.*;
|
||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.PreferReturnEnum;
|
||||
import ca.uhn.fhir.rest.api.SearchStyleEnum;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
|
||||
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
|
||||
import ca.uhn.fhir.rest.param.StringAndListParam;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.test.utilities.JettyUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
|
@ -23,8 +27,13 @@ import org.hl7.fhir.dstu3.model.*;
|
|||
import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent;
|
||||
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.junit.*;
|
||||
import org.junit.runners.MethodSorters;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.ArgumentMatcher;
|
||||
import org.mockito.ArgumentMatchers;
|
||||
|
@ -34,16 +43,20 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.mockito.Mockito.reset;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import ca.uhn.fhir.test.utilities.JettyUtil;
|
||||
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
@TestMethodOrder(MethodOrderer.Alphanumeric.class)
|
||||
public class AbstractJaxRsResourceProviderDstu3Test {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(AbstractJaxRsResourceProviderDstu3Test.class);
|
||||
|
@ -65,7 +78,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
assertEquals(id, Integer.parseInt(resource.getIdElement().getIdPart()));
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@AfterAll
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
JettyUtil.closeServer(jettyServer);
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
|
@ -114,7 +127,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.mock = TestJaxRsMockPatientRestProviderDstu3.mock;
|
||||
idCaptor = ArgumentCaptor.forClass(IdType.class);
|
||||
|
@ -329,14 +342,14 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
|
||||
/** Search - Subsetting (_summary and _elements) */
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void testSummary() {
|
||||
Object response = client.search().forResource(Patient.class)
|
||||
.returnBundle(org.hl7.fhir.dstu3.model.Bundle.class).execute();
|
||||
}
|
||||
|
||||
/** Transaction - Server */
|
||||
// @Ignore
|
||||
// @Disabled
|
||||
// @Test
|
||||
// public void testTransaction() {
|
||||
// ca.uhn.fhir.model.api.Bundle bundle = new ca.uhn.fhir.model.api.Bundle();
|
||||
|
@ -370,7 +383,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Ignore
|
||||
@Disabled
|
||||
@Test
|
||||
public void testResourceNotFound() throws Exception {
|
||||
when(mock.update(idCaptor.capture(), patientCaptor.capture(), conditionalCaptor.capture())).thenThrow(ResourceNotFoundException.class);
|
||||
|
@ -420,7 +433,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
assertNotNull(mO.getOperationOutcome());
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void setUpClass() throws Exception {
|
||||
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
|
||||
context.setContextPath("/");
|
||||
|
|
|
@ -8,12 +8,19 @@ import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPageProvider;
|
|||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProvider;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.dstu2.composite.IdentifierDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.*;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Bundle;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Conformance;
|
||||
import ca.uhn.fhir.model.dstu2.resource.OperationOutcome;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Parameters;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.DateDt;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.model.primitive.UriDt;
|
||||
import ca.uhn.fhir.rest.api.*;
|
||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.PreferReturnEnum;
|
||||
import ca.uhn.fhir.rest.api.SearchStyleEnum;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
|
||||
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
|
||||
|
@ -21,14 +28,20 @@ import ca.uhn.fhir.rest.param.StringAndListParam;
|
|||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.rest.server.SimpleBundleProvider;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.test.utilities.JettyUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
||||
import org.junit.*;
|
||||
import org.junit.runners.MethodSorters;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Matchers;
|
||||
|
||||
|
@ -37,16 +50,20 @@ import java.util.Arrays;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.mockito.Mockito.reset;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import ca.uhn.fhir.test.utilities.JettyUtil;
|
||||
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
@TestMethodOrder(MethodOrderer.Alphanumeric.class)
|
||||
public class AbstractJaxRsResourceProviderTest {
|
||||
|
||||
private static IGenericClient client;
|
||||
|
@ -70,7 +87,7 @@ public class AbstractJaxRsResourceProviderTest {
|
|||
assertEquals(url, resource.getId().getValueAsString().substring(serverBase.length() - 1));
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@AfterAll
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
JettyUtil.closeServer(jettyServer);
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
|
@ -110,7 +127,7 @@ public class AbstractJaxRsResourceProviderTest {
|
|||
compareResultUrl("/Patient/1", result);
|
||||
}
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.mock = TestJaxRsMockPatientRestProvider.mock;
|
||||
idCaptor = ArgumentCaptor.forClass(IdDt.class);
|
||||
|
@ -308,7 +325,7 @@ public class AbstractJaxRsResourceProviderTest {
|
|||
|
||||
/** Search - Subsetting (_summary and _elements) */
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void testSummary() {
|
||||
Object response = client.search().forResource(Patient.class)
|
||||
.returnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class).execute();
|
||||
|
@ -332,7 +349,7 @@ public class AbstractJaxRsResourceProviderTest {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Ignore
|
||||
@Disabled
|
||||
@Test
|
||||
public void testResourceNotFound() throws Exception {
|
||||
when(mock.update(idCaptor.capture(), patientCaptor.capture(), conditionalCaptor.capture())).thenThrow(ResourceNotFoundException.class);
|
||||
|
@ -417,7 +434,7 @@ public class AbstractJaxRsResourceProviderTest {
|
|||
});
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void setUpClass() throws Exception {
|
||||
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
|
||||
context.setContextPath("/");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package ca.uhn.fhir.jaxrs.server.interceptor;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.isNull;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
@ -13,8 +13,8 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.ws.rs.core.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.AbstractJaxRsProvider;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProvider;
|
||||
|
@ -28,7 +28,7 @@ public class JaxRsExceptionInterceptorTest {
|
|||
JaxRsExceptionInterceptor interceptor = new JaxRsExceptionInterceptor();
|
||||
private InvocationContext context;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
interceptor = new JaxRsExceptionInterceptor();
|
||||
context = mock(InvocationContext.class);
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package ca.uhn.fhir.jaxrs.server.interceptor;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import javax.ejb.ApplicationException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import ca.uhn.fhir.rest.server.exceptions.ForbiddenOperationException;
|
||||
|
||||
|
|
|
@ -1,22 +1,6 @@
|
|||
package ca.uhn.fhir.jaxrs.server.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.dstu3.model.IdType;
|
||||
import org.hl7.fhir.dstu3.model.Parameters;
|
||||
import org.hl7.fhir.dstu3.model.Patient;
|
||||
import org.hl7.fhir.dstu3.model.StringType;
|
||||
import org.junit.Before;
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.Test;
|
||||
import org.junit.runners.MethodSorters;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderDstu3;
|
||||
import ca.uhn.fhir.jaxrs.server.util.JaxRsMethodBindings;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.Operation;
|
||||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||
|
@ -28,32 +12,46 @@ import ca.uhn.fhir.rest.api.MethodOutcome;
|
|||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.rest.server.exceptions.NotImplementedOperationException;
|
||||
import org.hl7.fhir.dstu3.model.IdType;
|
||||
import org.hl7.fhir.dstu3.model.Parameters;
|
||||
import org.hl7.fhir.dstu3.model.Patient;
|
||||
import org.hl7.fhir.dstu3.model.StringType;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@FixMethodOrder(MethodSorters.DEFAULT)
|
||||
public class JaxRsMethodBindingsDstu3Test {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
JaxRsMethodBindings.getClassBindings().clear();
|
||||
}
|
||||
|
||||
@Test(expected = NotImplementedOperationException.class)
|
||||
public void testFindMethodsForProviderNotDefinedMappingMethods() {
|
||||
new TestJaxRsDummyPatientProviderDstu3().getBindings().getBinding(RestOperationTypeEnum.UPDATE, "");
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
JaxRsMethodBindings.getClassBindings().clear();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testFindMethodsForProviderNotDefinedMappingMethods() {
|
||||
assertThrows(NotImplementedOperationException.class, () -> {
|
||||
new TestJaxRsDummyPatientProviderDstu3().getBindings().getBinding(RestOperationTypeEnum.UPDATE, "");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindMethodsForProviderWithMethods() {
|
||||
class TestFindPatientProvider extends TestJaxRsDummyPatientProviderDstu3 {
|
||||
@Search
|
||||
public List<Patient> search(@RequiredParam(name = Patient.SP_NAME) final StringParam name) {
|
||||
return null;
|
||||
}
|
||||
@Search
|
||||
public List<Patient> search(@RequiredParam(name = Patient.SP_NAME) final StringParam name) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
new TestFindPatientProvider();
|
||||
assertEquals(TestFindPatientProvider.class, new TestFindPatientProvider().getBindings().getBinding(RestOperationTypeEnum.SEARCH_TYPE, "").getMethod().getDeclaringClass());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testFindMethodsFor2ProvidersWithMethods() {
|
||||
class TestFindPatientProvider extends TestJaxRsDummyPatientProviderDstu3 {
|
||||
|
@ -63,15 +61,15 @@ public class JaxRsMethodBindingsDstu3Test {
|
|||
}
|
||||
}
|
||||
class TestUpdatePatientProvider extends TestJaxRsDummyPatientProviderDstu3 {
|
||||
@Update
|
||||
public MethodOutcome update(@IdParam final IdType theId, @ResourceParam final Patient patient) {
|
||||
@Update
|
||||
public MethodOutcome update(@IdParam final IdType theId, @ResourceParam final Patient patient) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
assertEquals(TestFindPatientProvider.class, new TestFindPatientProvider().getBindings().getBinding(RestOperationTypeEnum.SEARCH_TYPE, "").getMethod().getDeclaringClass());
|
||||
assertEquals(TestUpdatePatientProvider.class, new TestUpdatePatientProvider().getBindings().getBinding(RestOperationTypeEnum.UPDATE, "").getMethod().getDeclaringClass());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testFindMethodsWithDoubleMethodsDeclaration() {
|
||||
class TestDoubleSearchProvider extends TestJaxRsDummyPatientProviderDstu3 {
|
||||
|
@ -79,7 +77,7 @@ public class JaxRsMethodBindingsDstu3Test {
|
|||
public List<Patient> search1(@RequiredParam(name = Patient.SP_NAME) final StringParam name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Search
|
||||
public List<Patient> search2(@RequiredParam(name = Patient.SP_NAME) final StringParam name) {
|
||||
return null;
|
||||
|
@ -88,12 +86,12 @@ public class JaxRsMethodBindingsDstu3Test {
|
|||
try {
|
||||
new TestDoubleSearchProvider();
|
||||
fail();
|
||||
} catch(IllegalArgumentException e) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertTrue(e.getMessage().contains("search1"));
|
||||
assertTrue(e.getMessage().contains("search2"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testFindMethodsWithMultipleMethods() {
|
||||
class TestFindPatientProvider extends TestJaxRsDummyPatientProviderDstu3 {
|
||||
|
@ -101,15 +99,18 @@ public class JaxRsMethodBindingsDstu3Test {
|
|||
public List<Patient> search(@RequiredParam(name = Patient.SP_NAME) final StringParam name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Update
|
||||
public MethodOutcome update(@IdParam final IdType theId, @ResourceParam final Patient patient) {
|
||||
return null;
|
||||
}
|
||||
@Operation(name = "firstMethod", idempotent = true, returnParameters = { @OperationParam(name = "return", type = StringType.class) })
|
||||
|
||||
@Operation(name = "firstMethod", idempotent = true, returnParameters = {@OperationParam(name = "return", type = StringType.class)})
|
||||
public Parameters firstMethod(@OperationParam(name = "dummy") StringType dummyInput) {
|
||||
return null;
|
||||
}
|
||||
@Operation(name = "secondMethod", returnParameters = { @OperationParam(name = "return", type = StringType.class) })
|
||||
|
||||
@Operation(name = "secondMethod", returnParameters = {@OperationParam(name = "return", type = StringType.class)})
|
||||
public Parameters secondMethod(@OperationParam(name = "dummy") StringType dummyInput) {
|
||||
return null;
|
||||
}
|
||||
|
@ -122,8 +123,8 @@ public class JaxRsMethodBindingsDstu3Test {
|
|||
try {
|
||||
bindings.getBinding(RestOperationTypeEnum.EXTENDED_OPERATION_TYPE, "$thirdMethod");
|
||||
fail();
|
||||
} catch(NotImplementedOperationException e){
|
||||
} catch (NotImplementedOperationException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,25 +4,22 @@ import ca.uhn.fhir.jaxrs.server.test.AbstractDummyPatientProvider;
|
|||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderR4;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderR4MimeType;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import org.junit.Before;
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.Test;
|
||||
import org.junit.runners.MethodSorters;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@FixMethodOrder(MethodSorters.DEFAULT)
|
||||
public class JaxRsMethodBindingsMimeTypeTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
JaxRsMethodBindings.getClassBindings().clear();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
JaxRsMethodBindings.getClassBindings().clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindMethodsFor2ProvidersWithMethods() {
|
||||
assertEquals(AbstractDummyPatientProvider.class, new TestJaxRsDummyPatientProviderR4().getBindings().getBinding(RestOperationTypeEnum.SEARCH_TYPE, "").getMethod().getDeclaringClass());
|
||||
assertEquals(AbstractDummyPatientProvider.class, new TestJaxRsDummyPatientProviderR4MimeType().getBindings().getBinding(RestOperationTypeEnum.SEARCH_TYPE, "").getMethod().getDeclaringClass());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,16 +1,5 @@
|
|||
package ca.uhn.fhir.jaxrs.server.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.Test;
|
||||
import org.junit.runners.MethodSorters;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProvider;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Parameters;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
|
@ -27,32 +16,42 @@ import ca.uhn.fhir.rest.api.MethodOutcome;
|
|||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.rest.server.exceptions.NotImplementedOperationException;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@FixMethodOrder(MethodSorters.DEFAULT)
|
||||
public class JaxRsMethodBindingsTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
JaxRsMethodBindings.getClassBindings().clear();
|
||||
}
|
||||
|
||||
@Test(expected = NotImplementedOperationException.class)
|
||||
public void testFindMethodsForProviderNotDefinedMappingMethods() {
|
||||
new TestJaxRsDummyPatientProvider().getBindings().getBinding(RestOperationTypeEnum.UPDATE, "");
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
JaxRsMethodBindings.getClassBindings().clear();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testFindMethodsForProviderNotDefinedMappingMethods() {
|
||||
assertThrows(NotImplementedOperationException.class, () -> {
|
||||
new TestJaxRsDummyPatientProvider().getBindings().getBinding(RestOperationTypeEnum.UPDATE, "");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindMethodsForProviderWithMethods() {
|
||||
class TestFindPatientProvider extends TestJaxRsDummyPatientProvider {
|
||||
@Search
|
||||
public List<Patient> search(@RequiredParam(name = Patient.SP_NAME) final StringParam name) {
|
||||
return null;
|
||||
}
|
||||
@Search
|
||||
public List<Patient> search(@RequiredParam(name = Patient.SP_NAME) final StringParam name) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
new TestFindPatientProvider();
|
||||
assertEquals(TestFindPatientProvider.class, new TestFindPatientProvider().getBindings().getBinding(RestOperationTypeEnum.SEARCH_TYPE, "").getMethod().getDeclaringClass());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testFindMethodsFor2ProvidersWithMethods() {
|
||||
class TestFindPatientProvider extends TestJaxRsDummyPatientProvider {
|
||||
|
@ -62,15 +61,15 @@ public class JaxRsMethodBindingsTest {
|
|||
}
|
||||
}
|
||||
class TestUpdatePatientProvider extends TestJaxRsDummyPatientProvider {
|
||||
@Update
|
||||
public MethodOutcome update(@IdParam final IdDt theId, @ResourceParam final Patient patient) {
|
||||
@Update
|
||||
public MethodOutcome update(@IdParam final IdDt theId, @ResourceParam final Patient patient) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
assertEquals(TestFindPatientProvider.class, new TestFindPatientProvider().getBindings().getBinding(RestOperationTypeEnum.SEARCH_TYPE, "").getMethod().getDeclaringClass());
|
||||
assertEquals(TestUpdatePatientProvider.class, new TestUpdatePatientProvider().getBindings().getBinding(RestOperationTypeEnum.UPDATE, "").getMethod().getDeclaringClass());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testFindMethodsWithDoubleMethodsDeclaration() {
|
||||
class TestDoubleSearchProvider extends TestJaxRsDummyPatientProvider {
|
||||
|
@ -78,7 +77,7 @@ public class JaxRsMethodBindingsTest {
|
|||
public List<Patient> search1(@RequiredParam(name = Patient.SP_NAME) final StringParam name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Search
|
||||
public List<Patient> search2(@RequiredParam(name = Patient.SP_NAME) final StringParam name) {
|
||||
return null;
|
||||
|
@ -87,12 +86,12 @@ public class JaxRsMethodBindingsTest {
|
|||
try {
|
||||
new TestDoubleSearchProvider();
|
||||
fail();
|
||||
} catch(IllegalArgumentException e) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertTrue(e.getMessage().contains("search1"));
|
||||
assertTrue(e.getMessage().contains("search2"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testFindMethodsWithMultipleMethods() {
|
||||
class TestFindPatientProvider extends TestJaxRsDummyPatientProvider {
|
||||
|
@ -100,15 +99,18 @@ public class JaxRsMethodBindingsTest {
|
|||
public List<Patient> search(@RequiredParam(name = Patient.SP_NAME) final StringParam name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Update
|
||||
public MethodOutcome update(@IdParam final IdDt theId, @ResourceParam final Patient patient) {
|
||||
return null;
|
||||
}
|
||||
@Operation(name = "firstMethod", idempotent = true, returnParameters = { @OperationParam(name = "return", type = StringDt.class) })
|
||||
|
||||
@Operation(name = "firstMethod", idempotent = true, returnParameters = {@OperationParam(name = "return", type = StringDt.class)})
|
||||
public Parameters firstMethod(@OperationParam(name = "dummy") StringDt dummyInput) {
|
||||
return null;
|
||||
}
|
||||
@Operation(name = "secondMethod", returnParameters = { @OperationParam(name = "return", type = StringDt.class) })
|
||||
|
||||
@Operation(name = "secondMethod", returnParameters = {@OperationParam(name = "return", type = StringDt.class)})
|
||||
public Parameters secondMethod(@OperationParam(name = "dummy") StringDt dummyInput) {
|
||||
return null;
|
||||
}
|
||||
|
@ -121,8 +123,8 @@ public class JaxRsMethodBindingsTest {
|
|||
try {
|
||||
bindings.getBinding(RestOperationTypeEnum.EXTENDED_OPERATION_TYPE, "$thirdMethod");
|
||||
fail();
|
||||
} catch(NotImplementedOperationException e){
|
||||
} catch (NotImplementedOperationException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,10 +3,11 @@ package ca.uhn.fhir.jaxrs.server.util;
|
|||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderDstu3;
|
||||
import ca.uhn.fhir.rest.api.RequestTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import ca.uhn.fhir.rest.server.exceptions.NotImplementedOperationException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
|
@ -15,7 +16,7 @@ import java.io.IOException;
|
|||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class JaxRsRequestDstu3Test {
|
||||
|
@ -29,7 +30,7 @@ public class JaxRsRequestDstu3Test {
|
|||
private ResteasyHttpHeaders headers;
|
||||
private TestJaxRsDummyPatientProviderDstu3 provider;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws URISyntaxException {
|
||||
details = createRequestDetails();
|
||||
}
|
||||
|
@ -66,14 +67,18 @@ public class JaxRsRequestDstu3Test {
|
|||
assertTrue(response == details.getResponse());
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void testGetReader() throws IOException {
|
||||
details.getReader();
|
||||
@Test
|
||||
public void testGetReader() {
|
||||
assertThrows(UnsupportedOperationException.class, ()->{
|
||||
details.getReader();
|
||||
});
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
@Test
|
||||
public void testGetInputStream() {
|
||||
details.getInputStream();
|
||||
assertThrows(UnsupportedOperationException.class, ()->{
|
||||
details.getInputStream();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -3,10 +3,11 @@ package ca.uhn.fhir.jaxrs.server.util;
|
|||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProvider;
|
||||
import ca.uhn.fhir.rest.api.RequestTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import ca.uhn.fhir.rest.server.exceptions.NotImplementedOperationException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
|
@ -15,7 +16,7 @@ import java.io.IOException;
|
|||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class JaxRsRequestTest {
|
||||
|
@ -29,7 +30,7 @@ public class JaxRsRequestTest {
|
|||
private ResteasyHttpHeaders headers;
|
||||
private TestJaxRsDummyPatientProvider provider;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws URISyntaxException {
|
||||
details = createRequestDetails();
|
||||
}
|
||||
|
@ -66,14 +67,18 @@ public class JaxRsRequestTest {
|
|||
assertTrue(response == details.getResponse());
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
@Test
|
||||
public void testGetReader() throws IOException {
|
||||
details.getReader();
|
||||
assertThrows(UnsupportedOperationException.class,()->{
|
||||
details.getReader();
|
||||
});
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
@Test
|
||||
public void testGetInputStream() {
|
||||
details.getInputStream();
|
||||
assertThrows(UnsupportedOperationException.class, ()->{
|
||||
details.getInputStream();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package ca.uhn.fhir.jaxrs.server.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
|
@ -12,8 +12,8 @@ import javax.ws.rs.core.Response;
|
|||
|
||||
import org.hl7.fhir.dstu3.model.*;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBinary;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
|
@ -27,7 +27,7 @@ public class JaxRsResponseDstu3Test {
|
|||
private Bundle bundle;
|
||||
private Set<SummaryEnum> theSummaryMode;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws URISyntaxException {
|
||||
request = new JaxRsRequestDstu3Test().createRequestDetails();
|
||||
this.response = (JaxRsResponse) request.getResponse();
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package ca.uhn.fhir.jaxrs.server.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
|
@ -13,8 +13,8 @@ import javax.ws.rs.core.Response;
|
|||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBinary;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import ca.uhn.fhir.model.dstu2.resource.Binary;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
|
@ -29,7 +29,7 @@ public class JaxRsResponseTest {
|
|||
private JaxRsRequest request;
|
||||
private Set<SummaryEnum> theSummaryMode;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws URISyntaxException {
|
||||
request = new JaxRsRequestTest().createRequestDetails();
|
||||
this.response = (JaxRsResponse) request.getResponse();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package ca.uhn.fhir.jaxrs.server.example;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -12,7 +12,7 @@ import org.eclipse.jetty.servlet.ServletContextHandler;
|
|||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.hl7.fhir.dstu3.model.*;
|
||||
import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent;
|
||||
import org.junit.*;
|
||||
import org.junit.jupiter.api.*; import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.client.JaxRsRestfulClientFactory;
|
||||
|
@ -31,13 +31,13 @@ public class JaxRsPatientProviderDstu3Test {
|
|||
private static int ourPort;
|
||||
private static Server jettyServer;
|
||||
|
||||
@AfterClass
|
||||
@AfterAll
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
JettyUtil.closeServer(jettyServer);
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void setUpClass()
|
||||
throws Exception {
|
||||
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
|
||||
|
@ -124,7 +124,7 @@ public class JaxRsPatientProviderDstu3Test {
|
|||
|
||||
/** Search - Subsetting (_summary and _elements) */
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void testSummary() {
|
||||
client.search()
|
||||
.forResource(Patient.class)
|
||||
|
@ -202,7 +202,7 @@ public class JaxRsPatientProviderDstu3Test {
|
|||
|
||||
/** Conformance - Server */
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void testConformance() {
|
||||
final CapabilityStatement conf = client.fetchConformance().ofType(CapabilityStatement.class).execute();
|
||||
System.out.println(conf.getRest().get(0).getResource().get(0).getType());
|
||||
|
@ -231,7 +231,7 @@ public class JaxRsPatientProviderDstu3Test {
|
|||
.execute();
|
||||
String resultValue = outParams.getParameter().get(0).getValue().toString();
|
||||
System.out.println(resultValue);
|
||||
assertEquals("expected but found : "+ resultValue, resultValue.contains("myAwesomeDummyValue"), true);
|
||||
assertEquals(resultValue.contains("myAwesomeDummyValue"), true, "expected but found : "+ resultValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -252,7 +252,7 @@ public class JaxRsPatientProviderDstu3Test {
|
|||
.execute();
|
||||
String resultValue = outParams.getParameter().get(0).getValue().toString();
|
||||
System.out.println(resultValue);
|
||||
assertEquals("expected but found : "+ resultValue, resultValue.contains("myAwesomeDummyValue"), true);
|
||||
assertEquals(resultValue.contains("myAwesomeDummyValue"), true, "expected but found : "+ resultValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -16,15 +16,15 @@ import org.eclipse.jetty.server.Server;
|
|||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.hl7.fhir.r4.model.*;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class JaxRsPatientProviderR4Test {
|
||||
|
||||
|
@ -34,13 +34,13 @@ public class JaxRsPatientProviderR4Test {
|
|||
private static int ourPort;
|
||||
private static Server jettyServer;
|
||||
|
||||
@AfterClass
|
||||
@AfterAll
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
JettyUtil.closeServer(jettyServer);
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void setUpClass()
|
||||
throws Exception {
|
||||
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
|
||||
|
@ -135,7 +135,7 @@ public class JaxRsPatientProviderR4Test {
|
|||
|
||||
/** Search - Subsetting (_summary and _elements) */
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void testSummary() {
|
||||
client.search()
|
||||
.forResource(Patient.class)
|
||||
|
@ -209,7 +209,7 @@ public class JaxRsPatientProviderR4Test {
|
|||
}
|
||||
|
||||
/** Transaction - Server */
|
||||
@Ignore
|
||||
@Disabled
|
||||
@Test
|
||||
public void testTransaction() {
|
||||
Bundle bundle = new Bundle();
|
||||
|
@ -226,7 +226,7 @@ public class JaxRsPatientProviderR4Test {
|
|||
|
||||
/** Conformance - Server */
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void testConformance() {
|
||||
final CapabilityStatement caps = client.capabilities().ofType(CapabilityStatement.class).execute();
|
||||
System.out.println(caps.getRest().get(0).getResource().get(0).getType());
|
||||
|
@ -255,7 +255,7 @@ public class JaxRsPatientProviderR4Test {
|
|||
.execute();
|
||||
String resultValue = outParams.getParameter().get(0).getValue().toString();
|
||||
System.out.println(resultValue);
|
||||
assertEquals("expected but found : " + resultValue, resultValue.contains("myAwesomeDummyValue"), true);
|
||||
assertEquals(resultValue.contains("myAwesomeDummyValue"), true, "expected but found : " + resultValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -276,7 +276,7 @@ public class JaxRsPatientProviderR4Test {
|
|||
.execute();
|
||||
String resultValue = outParams.getParameter().get(0).getValue().toString();
|
||||
System.out.println(resultValue);
|
||||
assertEquals("expected but found : " + resultValue, resultValue.contains("myAwesomeDummyValue"), true);
|
||||
assertEquals(resultValue.contains("myAwesomeDummyValue"), true, "expected but found : " + resultValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package ca.uhn.fhir.jaxrs.server.example;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -9,8 +9,8 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.junit.*;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.*; import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.client.JaxRsRestfulClientFactory;
|
||||
|
@ -34,13 +34,13 @@ public class JaxRsPatientProviderTest {
|
|||
private static int ourPort;
|
||||
private static Server jettyServer;
|
||||
|
||||
@AfterClass
|
||||
@AfterAll
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
JettyUtil.closeServer(jettyServer);
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void setUpClass()
|
||||
throws Exception {
|
||||
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
|
||||
|
@ -135,7 +135,7 @@ public class JaxRsPatientProviderTest {
|
|||
|
||||
/** Search - Subsetting (_summary and _elements) */
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void testSummary() {
|
||||
client.search()
|
||||
.forResource(Patient.class)
|
||||
|
@ -209,7 +209,7 @@ public class JaxRsPatientProviderTest {
|
|||
}
|
||||
|
||||
/** Transaction - Server */
|
||||
@Ignore
|
||||
@Disabled
|
||||
@Test
|
||||
public void testTransaction() {
|
||||
Bundle bundle = new Bundle();
|
||||
|
@ -226,7 +226,7 @@ public class JaxRsPatientProviderTest {
|
|||
|
||||
/** Conformance - Server */
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void testConformance() {
|
||||
final Conformance conf = client.fetchConformance().ofType(Conformance.class).execute();
|
||||
System.out.println(conf.getRest().get(0).getResource().get(0).getType());
|
||||
|
@ -255,7 +255,7 @@ public class JaxRsPatientProviderTest {
|
|||
.execute();
|
||||
String resultValue = outParams.getParameter().get(0).getValue().toString();
|
||||
System.out.println(resultValue);
|
||||
assertEquals("expected but found : " + resultValue, resultValue.contains("myAwesomeDummyValue"), true);
|
||||
assertEquals(resultValue.contains("myAwesomeDummyValue"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -276,7 +276,7 @@ public class JaxRsPatientProviderTest {
|
|||
.execute();
|
||||
String resultValue = outParams.getParameter().get(0).getValue().toString();
|
||||
System.out.println(resultValue);
|
||||
assertEquals("expected but found : " + resultValue, resultValue.contains("myAwesomeDummyValue"), true);
|
||||
assertEquals(resultValue.contains("myAwesomeDummyValue"), true, "expected but found : " + resultValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -248,11 +248,6 @@
|
|||
</dependency>
|
||||
|
||||
<!-- FHIR RI is pulled in for UCUM support, but we don't want any of its dependencies. -->
|
||||
<!-- <dependency> <groupId>me.fhir</groupId> <artifactId>fhir-dstu1</artifactId> <version>0.0.81.2489</version> <exclusions> <exclusion> <artifactId>Saxon-HE</artifactId> <groupId>net.sf.saxon</groupId>
|
||||
</exclusion> <exclusion> <artifactId>commons-discovery</artifactId> <groupId>commons-discovery</groupId> </exclusion> <exclusion> <artifactId>commons-codec</artifactId> <groupId>commons-codec</groupId>
|
||||
</exclusion> <exclusion> <artifactId>commons-logging</artifactId> <groupId>commons-logging</groupId> </exclusion> <exclusion> <artifactId>xpp3</artifactId> <groupId>xpp3</groupId> </exclusion> <exclusion>
|
||||
<artifactId>junit</artifactId> <groupId>junit</groupId> </exclusion> <exclusion> <artifactId>jdom</artifactId> <groupId>org.jdom</groupId> </exclusion> <exclusion> <artifactId>gson</artifactId> <groupId>com.google.code.gson</groupId>
|
||||
</exclusion> </exclusions> </dependency> -->
|
||||
|
||||
<!--
|
||||
For some reason JavaDoc crashed during site generation unless we have this dependency
|
||||
|
@ -298,17 +293,6 @@
|
|||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-test-utilities</artifactId>
|
||||
|
@ -578,6 +562,10 @@
|
|||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>javax.mail</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -605,6 +593,12 @@
|
|||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava-testlib</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
|
@ -740,8 +734,7 @@
|
|||
<version>dstu2</version>
|
||||
<configPackageBase>ca.uhn.fhir.jpa.config</configPackageBase>
|
||||
<packageBase>ca.uhn.fhir.jpa.rp.dstu2</packageBase>
|
||||
<targetResourceSpringBeansFile>hapi-fhir-server-resourceproviders-dstu2.xml
|
||||
</targetResourceSpringBeansFile>
|
||||
<targetResourceSpringBeansFile>hapi-fhir-server-resourceproviders-dstu2.xml</targetResourceSpringBeansFile>
|
||||
<baseResourceNames/>
|
||||
<excludeResourceNames>
|
||||
<!-- <excludeResourceName>OperationDefinition</excludeResourceName> <excludeResourceName>OperationOutcome</excludeResourceName> -->
|
||||
|
@ -757,8 +750,7 @@
|
|||
<version>dstu3</version>
|
||||
<configPackageBase>ca.uhn.fhir.jpa.config</configPackageBase>
|
||||
<packageBase>ca.uhn.fhir.jpa.rp.dstu3</packageBase>
|
||||
<targetResourceSpringBeansFile>hapi-fhir-server-resourceproviders-dstu3.xml
|
||||
</targetResourceSpringBeansFile>
|
||||
<targetResourceSpringBeansFile>hapi-fhir-server-resourceproviders-dstu3.xml</targetResourceSpringBeansFile>
|
||||
<baseResourceNames></baseResourceNames>
|
||||
<excludeResourceNames>
|
||||
</excludeResourceNames>
|
||||
|
@ -773,8 +765,7 @@
|
|||
<version>r4</version>
|
||||
<configPackageBase>ca.uhn.fhir.jpa.config</configPackageBase>
|
||||
<packageBase>ca.uhn.fhir.jpa.rp.r4</packageBase>
|
||||
<targetResourceSpringBeansFile>hapi-fhir-server-resourceproviders-r4.xml
|
||||
</targetResourceSpringBeansFile>
|
||||
<targetResourceSpringBeansFile>hapi-fhir-server-resourceproviders-r4.xml</targetResourceSpringBeansFile>
|
||||
<baseResourceNames></baseResourceNames>
|
||||
<excludeResourceNames>
|
||||
</excludeResourceNames>
|
||||
|
@ -789,8 +780,7 @@
|
|||
<version>r5</version>
|
||||
<configPackageBase>ca.uhn.fhir.jpa.config</configPackageBase>
|
||||
<packageBase>ca.uhn.fhir.jpa.rp.r5</packageBase>
|
||||
<targetResourceSpringBeansFile>hapi-fhir-server-resourceproviders-r5.xml
|
||||
</targetResourceSpringBeansFile>
|
||||
<targetResourceSpringBeansFile>hapi-fhir-server-resourceproviders-r5.xml</targetResourceSpringBeansFile>
|
||||
<baseResourceNames></baseResourceNames>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
|
@ -285,11 +285,6 @@ public class TestUtil {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public static void clearAllStaticFieldsForUnitTest() {
|
||||
ca.uhn.fhir.util.TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
public static InstantType getTimestamp(IBaseResource resource) {
|
||||
return new InstantType(new Date(resource.getMeta().getLastUpdated().getTime()));
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package ca.uhn.fhir.jpa.binstore;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.hamcrest.Matchers.matchesPattern;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
public class BaseBinaryStorageSvcImplTest {
|
||||
|
||||
|
|
|
@ -5,9 +5,9 @@ import ca.uhn.fhir.jpa.dao.r4.BaseJpaR4Test;
|
|||
import ca.uhn.fhir.jpa.model.entity.BinaryStorageEntity;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import org.hl7.fhir.r4.model.IdType;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
@ -22,15 +22,15 @@ import java.sql.Blob;
|
|||
import java.sql.SQLException;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.matchesPattern;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
@ -45,12 +45,12 @@ public class DatabaseBlobBinaryStorageSvcImplTest extends BaseJpaR4Test {
|
|||
@Autowired
|
||||
private DaoConfig myDaoConfig;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void backupDaoConfig() {
|
||||
defaultPreloadBlobFromInputStream = myDaoConfig.isPreloadBlobFromInputStream();
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void restoreDaoConfig() {
|
||||
myDaoConfig.setPreloadBlobFromInputStream(defaultPreloadBlobFromInputStream);
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
|||
import org.apache.commons.io.FileUtils;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.r4.model.IdType;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -16,7 +16,7 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class FilesystemBinaryStorageSvcImplTest {
|
||||
|
||||
|
@ -25,13 +25,13 @@ public class FilesystemBinaryStorageSvcImplTest {
|
|||
private File myPath;
|
||||
private FilesystemBinaryStorageSvcImpl mySvc;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void before() {
|
||||
myPath = new File("./target/fstmp");
|
||||
mySvc = new FilesystemBinaryStorageSvcImpl(myPath.getAbsolutePath());
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void after() throws IOException {
|
||||
FileUtils.deleteDirectory(myPath);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package ca.uhn.fhir.jpa.binstore;
|
||||
|
||||
import org.hl7.fhir.r4.model.IdType;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
public class NullBinaryStorageSvcImplTest {
|
||||
|
||||
|
@ -14,33 +15,45 @@ public class NullBinaryStorageSvcImplTest {
|
|||
assertFalse(mySvc.shouldStoreBlob(1, new IdType("Patient/2"), "application/json"));
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
@Test
|
||||
public void storeBlob() {
|
||||
mySvc.storeBlob(null, null, null, null);
|
||||
assertThrows(UnsupportedOperationException.class, () -> {
|
||||
mySvc.storeBlob(null, null, null, null);
|
||||
});
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
@Test
|
||||
public void fetchBlobDetails() {
|
||||
mySvc.fetchBlobDetails(null, null);
|
||||
assertThrows(UnsupportedOperationException.class, () -> {
|
||||
mySvc.fetchBlobDetails(null, null);
|
||||
});
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
@Test
|
||||
public void writeBlob() {
|
||||
mySvc.writeBlob(null, null, null);
|
||||
assertThrows(UnsupportedOperationException.class, () -> {
|
||||
mySvc.writeBlob(null, null, null);
|
||||
});
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
@Test
|
||||
public void expungeBlob() {
|
||||
mySvc.expungeBlob(null, null);
|
||||
assertThrows(UnsupportedOperationException.class, () -> {
|
||||
mySvc.expungeBlob(null, null);
|
||||
});
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
@Test
|
||||
public void fetchBlob() {
|
||||
mySvc.fetchBlob(null, null);
|
||||
assertThrows(UnsupportedOperationException.class, () -> {
|
||||
mySvc.fetchBlob(null, null);
|
||||
});
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
@Test
|
||||
public void newBlobId() {
|
||||
mySvc.newBlobId();
|
||||
assertThrows(UnsupportedOperationException.class, () -> {
|
||||
mySvc.newBlobId();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package ca.uhn.fhir.jpa.bulk;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.jpa.bulk.api.IBulkDataExportSvc;
|
||||
import ca.uhn.fhir.jpa.bulk.model.BulkExportResponseJson;
|
||||
import ca.uhn.fhir.jpa.bulk.model.BulkJobStatusEnum;
|
||||
|
@ -28,14 +29,14 @@ import org.hl7.fhir.r4.model.IdType;
|
|||
import org.hl7.fhir.r4.model.InstantType;
|
||||
import org.hl7.fhir.r4.model.Parameters;
|
||||
import org.hl7.fhir.r4.model.StringType;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -44,24 +45,24 @@ import java.util.Date;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.eq;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class BulkDataExportProviderTest {
|
||||
|
||||
private static final String A_JOB_ID = "0000000-AAAAAA";
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(BulkDataExportProviderTest.class);
|
||||
private Server myServer;
|
||||
private FhirContext myCtx = FhirContext.forR4();
|
||||
private FhirContext myCtx = FhirContext.forCached(FhirVersionEnum.R4);
|
||||
private int myPort;
|
||||
@Mock
|
||||
private IBulkDataExportSvc myBulkDataExportSvc;
|
||||
|
@ -75,13 +76,13 @@ public class BulkDataExportProviderTest {
|
|||
@Captor
|
||||
private ArgumentCaptor<Set<String>> myFiltersCaptor;
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void after() throws Exception {
|
||||
JettyUtil.closeServer(myServer);
|
||||
myClient.close();
|
||||
}
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void start() throws Exception {
|
||||
myServer = new Server(0);
|
||||
|
||||
|
@ -154,7 +155,7 @@ public class BulkDataExportProviderTest {
|
|||
String url = "http://localhost:" + myPort + "/" + JpaConstants.OPERATION_EXPORT
|
||||
+ "?" + JpaConstants.PARAM_EXPORT_OUTPUT_FORMAT + "=" + UrlUtil.escapeUrlParam(Constants.CT_FHIR_NDJSON)
|
||||
+ "&" + JpaConstants.PARAM_EXPORT_TYPE + "=" + UrlUtil.escapeUrlParam("Patient, Practitioner")
|
||||
+ "&" + JpaConstants.PARAM_EXPORT_SINCE+ "="+ UrlUtil.escapeUrlParam(now.getValueAsString())
|
||||
+ "&" + JpaConstants.PARAM_EXPORT_SINCE + "=" + UrlUtil.escapeUrlParam(now.getValueAsString())
|
||||
+ "&" + JpaConstants.PARAM_EXPORT_TYPE_FILTER + "=" + UrlUtil.escapeUrlParam("Patient?identifier=foo");
|
||||
|
||||
HttpGet get = new HttpGet(url);
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.hl7.fhir.r4.model.Binary;
|
|||
import org.hl7.fhir.r4.model.InstantType;
|
||||
import org.hl7.fhir.r4.model.Observation;
|
||||
import org.hl7.fhir.r4.model.Patient;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
|
@ -45,16 +45,16 @@ import java.util.stream.Collectors;
|
|||
|
||||
import static org.awaitility.Awaitility.await;
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
public class BulkDataExportSvcImplR4Test extends BaseJpaR4Test {
|
||||
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(BulkDataExportSvcImplR4Test.class);
|
||||
public static final String TEST_FILTER = "Patient?gender=female";
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(BulkDataExportSvcImplR4Test.class);
|
||||
@Autowired
|
||||
private IBulkExportJobDao myBulkExportJobDao;
|
||||
@Autowired
|
||||
|
@ -168,7 +168,7 @@ public class BulkDataExportSvcImplR4Test extends BaseJpaR4Test {
|
|||
// Check the status
|
||||
IBulkDataExportSvc.JobInfo status = myBulkDataExportSvc.getJobInfoOrThrowResourceNotFound(jobDetails.getJobId());
|
||||
assertEquals(BulkJobStatusEnum.SUBMITTED, status.getStatus());
|
||||
assertEquals("/$export?_outputFormat=application%2Ffhir%2Bndjson&_type=Observation,Patient&_typeFilter="+TEST_FILTER, status.getRequest());
|
||||
assertEquals("/$export?_outputFormat=application%2Ffhir%2Bndjson&_type=Observation,Patient&_typeFilter=" + TEST_FILTER, status.getRequest());
|
||||
|
||||
// Run a scheduled pass to build the export
|
||||
myBulkDataExportSvc.buildExportFiles();
|
||||
|
@ -213,7 +213,7 @@ public class BulkDataExportSvcImplR4Test extends BaseJpaR4Test {
|
|||
JobExecution jobExecution = myBatchJobSubmitter.runJob(myBulkJob, paramBuilder.toJobParameters());
|
||||
|
||||
awaitJobCompletion(jobExecution);
|
||||
String jobUUID = (String)jobExecution.getExecutionContext().get("jobUUID");
|
||||
String jobUUID = (String) jobExecution.getExecutionContext().get("jobUUID");
|
||||
IBulkDataExportSvc.JobInfo jobInfo = myBulkDataExportSvc.getJobInfoOrThrowResourceNotFound(jobUUID);
|
||||
|
||||
assertThat(jobInfo.getStatus(), equalTo(BulkJobStatusEnum.COMPLETE));
|
||||
|
@ -375,7 +375,7 @@ public class BulkDataExportSvcImplR4Test extends BaseJpaR4Test {
|
|||
|
||||
// Run a scheduled pass to build the export
|
||||
myBulkDataExportSvc.buildExportFiles();
|
||||
|
||||
|
||||
awaitAllBulkJobCompletions();
|
||||
|
||||
// Fetch the job again
|
||||
|
|
|
@ -7,21 +7,22 @@ import org.hibernate.HibernateException;
|
|||
import org.hibernate.PersistentObjectException;
|
||||
import org.hibernate.StaleStateException;
|
||||
import org.hibernate.exception.ConstraintViolationException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class HapiFhirHibernateJpaDialectTest {
|
||||
|
||||
private HapiFhirHibernateJpaDialect mySvc;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void before() {
|
||||
mySvc = new HapiFhirHibernateJpaDialect(new HapiLocalizer());
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package ca.uhn.fhir.jpa.config;
|
||||
|
||||
import ca.uhn.fhir.jpa.util.TestUtil;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class JpaEntityTest {
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.sql.SQLException;
|
|||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@Configuration
|
||||
@Import(TestJPAConfig.class)
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.sql.Connection;
|
|||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@Configuration
|
||||
@Import(TestJPAConfig.class)
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.sql.Connection;
|
|||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@Configuration
|
||||
@Import({TestJPAConfig.class, BatchJobsConfig.class})
|
||||
|
@ -162,6 +162,7 @@ public class TestR4Config extends BaseJavaConfigR4 {
|
|||
extraProperties.put("hibernate.search.default.directory_provider", "local-heap");
|
||||
extraProperties.put("hibernate.search.lucene_version", "LUCENE_CURRENT");
|
||||
extraProperties.put("hibernate.search.autoregister_listeners", "true");
|
||||
extraProperties.put("hibernate.temp.use_jdbc_metadata_defaults","false");
|
||||
|
||||
return extraProperties;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import javax.sql.DataSource;
|
|||
import java.sql.Connection;
|
||||
import java.util.Properties;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@Configuration
|
||||
@Import(TestJPAConfig.class)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package ca.uhn.fhir.jpa.dao;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class BaseHapiFhirDaoTest {
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
|||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.test.BaseTest;
|
||||
import ca.uhn.fhir.test.utilities.LoggingRule;
|
||||
import ca.uhn.fhir.test.utilities.LoggingExtension;
|
||||
import ca.uhn.fhir.test.utilities.ProxyUtil;
|
||||
import ca.uhn.fhir.test.utilities.UnregisterScheduledProcessor;
|
||||
import ca.uhn.fhir.util.BundleUtil;
|
||||
|
@ -49,11 +49,11 @@ import org.hl7.fhir.dstu3.model.Resource;
|
|||
import org.hl7.fhir.instance.model.api.IBaseBundle;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
@ -83,8 +83,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import static ca.uhn.fhir.util.TestUtil.randomizeLocale;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
@ -110,8 +110,8 @@ public abstract class BaseJpaTest extends BaseTest {
|
|||
TestUtil.setShouldRandomizeTimezones(false);
|
||||
}
|
||||
|
||||
@Rule
|
||||
public LoggingRule myLoggingRule = new LoggingRule();
|
||||
@RegisterExtension
|
||||
public LoggingExtension myLoggingExtension = new LoggingExtension();
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
protected ServletRequestDetails mySrd;
|
||||
protected InterceptorService myRequestOperationCallback;
|
||||
|
@ -137,7 +137,7 @@ public abstract class BaseJpaTest extends BaseTest {
|
|||
@Autowired
|
||||
private FhirInstanceValidator myFhirInstanceValidator;
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void afterPerformCleanup() {
|
||||
BaseHapiFhirDao.setDisableIncrementOnUpdateForUnitTest(false);
|
||||
if (myCaptureQueriesListener != null) {
|
||||
|
@ -158,7 +158,7 @@ public abstract class BaseJpaTest extends BaseTest {
|
|||
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void afterValidateNoTransaction() {
|
||||
PlatformTransactionManager txManager = getTxManager();
|
||||
if (txManager instanceof JpaTransactionManager) {
|
||||
|
@ -185,14 +185,14 @@ public abstract class BaseJpaTest extends BaseTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void beforeInitPartitions() {
|
||||
if (myPartitionConfigSvc != null) {
|
||||
myPartitionConfigSvc.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void beforeInitMocks() {
|
||||
myRequestOperationCallback = new InterceptorService();
|
||||
|
||||
|
@ -419,18 +419,12 @@ public abstract class BaseJpaTest extends BaseTest {
|
|||
return retVal.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void beforeClassRandomizeLocale() {
|
||||
randomizeLocale();
|
||||
}
|
||||
|
||||
@SuppressWarnings("RedundantThrows")
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@AfterAll
|
||||
public static void afterClassShutdownDerby() {
|
||||
// DriverManager.getConnection("jdbc:derby:;shutdown=true");
|
||||
// try {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package ca.uhn.fhir.jpa.dao;
|
||||
|
||||
import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
public class DaoConfigTest {
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@ import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
|||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
@ -15,12 +15,12 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class SearchBuilderTest {
|
||||
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue