mirror of
https://github.com/hapifhir/hapi-fhir.git
synced 2025-02-16 18:05:19 +00:00
Support versioned docs (#6254)
* wip * Add new stuff * spotless * logs * wip * Support forVersion * test fixes
This commit is contained in:
parent
0f2eb08a77
commit
070f24ad01
@ -170,7 +170,16 @@ public enum VersionEnum {
|
||||
return values[values.length - 1];
|
||||
}
|
||||
|
||||
public static VersionEnum forVersion(String theVersionString) {
|
||||
String constantName = "V" + (theVersionString.replace('.', '_'));
|
||||
return valueOf(constantName);
|
||||
}
|
||||
|
||||
public boolean isNewerThan(VersionEnum theVersionEnum) {
|
||||
return ordinal() > theVersionEnum.ordinal();
|
||||
}
|
||||
|
||||
public String getVersionedDocsSlug() {
|
||||
return this.name().replace("V", "").replaceAll("_", ".");
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,54 @@
|
||||
package ca.uhn.fhir.util;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockedStatic;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.thymeleaf.util.VersionUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class VersionEnumDocsSlugTest {
|
||||
|
||||
@Test
|
||||
void testVersionedDocsSlugsWhileSnapshot() {
|
||||
try (MockedStatic<VersionUtil> versionUtil = Mockito.mockStatic(VersionUtil.class)) {
|
||||
versionUtil.when(VersionUtil::isSnapshot).thenReturn(true);
|
||||
|
||||
String versionedDocsSlug = VersionEnum.V5_0_1.getVersionedDocsSlug();
|
||||
assertThat(versionedDocsSlug).isEqualTo("5.0.1");
|
||||
|
||||
versionedDocsSlug = VersionEnum.V7_0_0.getVersionedDocsSlug();
|
||||
assertThat(versionedDocsSlug).isEqualTo("7.0.0");
|
||||
|
||||
versionedDocsSlug = VersionEnum.V7_4_0.getVersionedDocsSlug();
|
||||
assertThat(versionedDocsSlug).isEqualTo("7.4.0");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVersionedDocsNoSnapshot() {
|
||||
try (MockedStatic<VersionUtil> versionUtil = Mockito.mockStatic(VersionUtil.class)) {
|
||||
versionUtil.when(VersionUtil::isSnapshot).thenReturn(false);
|
||||
|
||||
String versionedDocsSlug = VersionEnum.V5_0_1.getVersionedDocsSlug();
|
||||
assertThat(versionedDocsSlug).isEqualTo("5.0.1");
|
||||
|
||||
versionedDocsSlug = VersionEnum.V7_0_0.getVersionedDocsSlug();
|
||||
assertThat(versionedDocsSlug).isEqualTo("7.0.0");
|
||||
|
||||
versionedDocsSlug = VersionEnum.V7_4_0.getVersionedDocsSlug();
|
||||
assertThat(versionedDocsSlug).isEqualTo("7.4.0");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -40,5 +40,4 @@ public class VersionEnumTest {
|
||||
assertThat(versions).contains(version);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,3 +1,22 @@
|
||||
/*-
|
||||
* #%L
|
||||
* HAPI FHIR JPA Server
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2024 Smile CDR, Inc.
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
package ca.uhn.fhir.jpa.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
Loading…
x
Reference in New Issue
Block a user