Merge pull request #133 from hapifhir/ks-20200212-meta-security

fixes a bug in Meta.getSecurity(String,String)
This commit is contained in:
Grahame Grieve 2020-02-13 14:04:30 +11:00 committed by GitHub
commit dcb1240e66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 790 additions and 688 deletions

View File

@ -277,7 +277,7 @@ public class Meta extends Type implements IBaseMetaType {
* <code>null</code> if none
*/
public Coding getSecurity(String theSystem, String theCode) {
for (Coding next : getTag()) {
for (Coding next : getSecurity()) {
if (ca.uhn.fhir.util.ObjectUtil.equals(next.getSystem(), theSystem) && ca.uhn.fhir.util.ObjectUtil.equals(next.getCode(), theCode)) {
return next;
}

View File

@ -0,0 +1,24 @@
package org.hl7.fhir.dstu2.test;
import org.hl7.fhir.dstu2.model.Coding;
import org.hl7.fhir.dstu2.model.Meta;
import org.junit.Test;
import static org.junit.Assert.*;
public class MetaTest {
public static String TEST_SYSTEM = "TEST_SYSTEM";
public static String TEST_CODE = "TEST_CODE";
@Test
public void testMetaSecurity() {
Meta meta = new Meta();
Coding coding = meta.addSecurity().setSystem(TEST_SYSTEM).setCode(TEST_CODE);
assertTrue(meta.hasSecurity());
assertNotNull(meta.getSecurity());
assertNotNull(meta.getSecurity(TEST_SYSTEM, TEST_CODE));
assertEquals(1, meta.getSecurity().size());
assertEquals(meta.getSecurity().get(0), meta.getSecurity(TEST_SYSTEM, TEST_CODE));
assertEquals(coding, meta.getSecurity(TEST_SYSTEM, TEST_CODE));
}
}

View File

@ -421,7 +421,7 @@ public class Meta extends Type implements IBaseMetaType {
* <code>null</code> if none
*/
public Coding getSecurity(String theSystem, String theCode) {
for (Coding next : getTag()) {
for (Coding next : getSecurity()) {
if (ca.uhn.fhir.util.ObjectUtil.equals(next.getSystem(), theSystem) && ca.uhn.fhir.util.ObjectUtil.equals(next.getCode(), theCode)) {
return next;
}

View File

@ -0,0 +1,26 @@
package org.hl7.fhir.dstu3.test;
import org.hl7.fhir.dstu3.model.Coding;
import org.hl7.fhir.dstu3.model.Meta;
import org.junit.Test;
import static org.junit.Assert.*;
public class MetaTest {
public static String TEST_SYSTEM = "TEST_SYSTEM";
public static String TEST_CODE = "TEST_CODE";
@Test
public void testMetaSecurity() {
Meta meta = new Meta();
Coding coding = meta.addSecurity().setSystem(TEST_SYSTEM).setCode(TEST_CODE);
assertTrue(meta.hasSecurity());
assertNotNull(meta.getSecurity());
assertNotNull(meta.getSecurity(TEST_SYSTEM, TEST_CODE));
assertEquals(1, meta.getSecurity().size());
assertEquals(meta.getSecurity().get(0), meta.getSecurity(TEST_SYSTEM, TEST_CODE));
assertEquals(meta.getSecurityFirstRep(), meta.getSecurity(TEST_SYSTEM, TEST_CODE));
assertEquals(coding, meta.getSecurity(TEST_SYSTEM, TEST_CODE));
}
}

View File

@ -476,7 +476,7 @@ public class Meta extends Type implements IBaseMetaType {
* <code>null</code> if none
*/
public Coding getSecurity(String theSystem, String theCode) {
for (Coding next : getTag()) {
for (Coding next : getSecurity()) {
if (ca.uhn.fhir.util.ObjectUtil.equals(next.getSystem(), theSystem) && ca.uhn.fhir.util.ObjectUtil.equals(next.getCode(), theCode)) {
return next;
}

View File

@ -0,0 +1,26 @@
package org.hl7.fhir.r4.test;
import org.hl7.fhir.r4.model.Coding;
import org.hl7.fhir.r4.model.Meta;
import org.junit.Test;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
public class MetaTest {
public static String TEST_SYSTEM = "TEST_SYSTEM";
public static String TEST_CODE = "TEST_CODE";
@Test
public void testMetaSecurity() {
Meta meta = new Meta();
Coding coding = meta.addSecurity().setSystem(TEST_SYSTEM).setCode(TEST_CODE);
assertTrue(meta.hasSecurity());
assertNotNull(meta.getSecurity());
assertNotNull(meta.getSecurity(TEST_SYSTEM, TEST_CODE));
assertEquals(1, meta.getSecurity().size());
assertEquals(meta.getSecurity().get(0), meta.getSecurity(TEST_SYSTEM, TEST_CODE));
assertEquals(meta.getSecurityFirstRep(), meta.getSecurity(TEST_SYSTEM, TEST_CODE));
assertEquals(coding, meta.getSecurity(TEST_SYSTEM, TEST_CODE));
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,26 @@
package org.hl7.fhir.r5.test;
import org.hl7.fhir.r5.model.Coding;
import org.hl7.fhir.r5.model.Meta;
import org.junit.Test;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
public class MetaTest {
public static String TEST_SYSTEM = "TEST_SYSTEM";
public static String TEST_CODE = "TEST_CODE";
@Test
public void testMetaSecurity() {
Meta meta = new Meta();
Coding coding = meta.addSecurity().setSystem(TEST_SYSTEM).setCode(TEST_CODE);
assertTrue(meta.hasSecurity());
assertNotNull(meta.getSecurity());
assertNotNull(meta.getSecurity(TEST_SYSTEM, TEST_CODE));
assertEquals(1, meta.getSecurity().size());
assertEquals(meta.getSecurity().get(0), meta.getSecurity(TEST_SYSTEM, TEST_CODE));
assertEquals(meta.getSecurityFirstRep(), meta.getSecurity(TEST_SYSTEM, TEST_CODE));
assertEquals(coding, meta.getSecurity(TEST_SYSTEM, TEST_CODE));
}
}