use of junitparams.naming.TestCaseName in project mod-inventory-storage by folio-org.
the class ItemEffectiveCallNumberComponentsTest method canCalculateEffectiveCallNumberPropertyOnCreate.
@Test
@Parameters(source = ItemEffectiveCallNumberComponentsTestData.class, method = "createPropertiesParams")
@TestCaseName("[{index}]: {params}")
public void canCalculateEffectiveCallNumberPropertyOnCreate(CallNumberComponentPropertyNames callNumberProperties, String holdingsPropertyValue, String itemPropertyValue) {
final String effectiveValue = StringUtils.firstNonBlank(itemPropertyValue, holdingsPropertyValue);
IndividualResource holdings = createHoldingsWithPropertySetAndInstance(callNumberProperties.holdingsPropertyName, holdingsPropertyValue);
IndividualResource createdItem = itemsClient.create(nodWithNoBarcode(holdings.getId()).put(callNumberProperties.itemPropertyName, itemPropertyValue));
assertThat(createdItem.getJson().getString(callNumberProperties.itemPropertyName), is(itemPropertyValue));
Response getResponse = itemsClient.getById(createdItem.getId());
assertThat(getResponse.getStatusCode(), is(HttpURLConnection.HTTP_OK));
JsonObject effectiveCallNumberComponents = getResponse.getJson().getJsonObject("effectiveCallNumberComponents");
assertNotNull(effectiveCallNumberComponents);
assertThat(effectiveCallNumberComponents.getString(callNumberProperties.effectivePropertyName), is(effectiveValue));
}
use of junitparams.naming.TestCaseName in project jsonschema-generator by victools.
the class SchemaGeneratorComplexTypesTest method testGenerateSchema.
@Test
@Parameters
@TestCaseName(value = "{method}({0}) [{index}]")
public void testGenerateSchema(String caseTitle, OptionPreset preset, Class<?> targetType, Module testModule) throws Exception {
final SchemaVersion schemaVersion = SchemaVersion.DRAFT_7;
SchemaGeneratorConfigBuilder configBuilder = new SchemaGeneratorConfigBuilder(schemaVersion, preset);
configBuilder.with(testModule);
SchemaGenerator generator = new SchemaGenerator(configBuilder.build());
JsonNode result = generator.generateSchema(targetType);
// ensure that the generated definition keys are valid URIs without any characters requiring encoding
JsonNode definitions = result.get(SchemaKeyword.TAG_DEFINITIONS.forVersion(schemaVersion));
if (definitions instanceof ObjectNode) {
Iterator<String> definitionKeys = ((ObjectNode) definitions).fieldNames();
while (definitionKeys.hasNext()) {
String key = definitionKeys.next();
Assert.assertEquals(key, new URI(key).toASCIIString());
}
}
JSONAssert.assertEquals('\n' + result.toString() + '\n', TestUtils.loadResource(this.getClass(), caseTitle + ".json"), result.toString(), JSONCompareMode.STRICT);
}
use of junitparams.naming.TestCaseName in project jsonschema-generator by victools.
the class SchemaDefinitionNamingStrategyTest method testExampleStrategy.
@Test
@Parameters
@TestCaseName(value = "{method}({0}, {3} | {4}) [{index}]")
public void testExampleStrategy(String caseTitle, SchemaDefinitionNamingStrategy strategy, ResolvedType type, String expectedUriCompatibleName, String expectedPlainName) {
Mockito.when(this.key.getType()).thenReturn(type);
String result = strategy.getDefinitionNameForKey(this.key, this.generationContext);
// before the produced name is used in an actual schema, the SchemaCleanUpUtils come into play one way or another
SchemaCleanUpUtils cleanUpUtils = new SchemaCleanUpUtils(null);
Assert.assertEquals(expectedUriCompatibleName, cleanUpUtils.ensureDefinitionKeyIsUriCompatible(result));
Assert.assertEquals(expectedPlainName, cleanUpUtils.ensureDefinitionKeyIsPlain(result));
}
use of junitparams.naming.TestCaseName in project jsonschema-generator by victools.
the class JavaxValidationModuleTest method testValidationGroupSetting.
@Test
@Parameters
@TestCaseName("{method}({0}, {1}, {2}) [{index}]")
public void testValidationGroupSetting(String testCase, String fieldName, Boolean expectedResult, Class<?>[] validationGroups) {
JavaxValidationModule module = new JavaxValidationModule();
if (validationGroups != null) {
module.forValidationGroups(validationGroups);
}
module.applyToConfigBuilder(this.configBuilder);
ArgumentCaptor<ConfigFunction<FieldScope, Boolean>> captor = ArgumentCaptor.forClass(ConfigFunction.class);
Mockito.verify(this.fieldConfigPart).withNullableCheck(captor.capture());
TestType testType = new TestType(TestClassForValidationGroups.class);
FieldScope field = testType.getMemberField(fieldName);
Boolean result = captor.getValue().apply(field);
Assert.assertEquals(expectedResult, result);
}
use of junitparams.naming.TestCaseName in project kubernetes-plugin by jenkinsci.
the class PodTemplateBuilderTest method testBuildFromTemplate.
@Test
@TestCaseName("{method}(directConnection={0})")
@Parameters({ "true", "false" })
public void testBuildFromTemplate(boolean directConnection) throws Exception {
cloud.setDirectConnection(directConnection);
PodTemplate template = new PodTemplate();
template.setRunAsUser("1000");
template.setRunAsGroup("1000");
template.setSupplementalGroups("5001,5002");
template.setHostNetwork(false);
List<PodVolume> volumes = new ArrayList<PodVolume>();
volumes.add(new HostPathVolume("/host/data", "/container/data"));
volumes.add(new EmptyDirVolume("/empty/dir", false));
template.setVolumes(volumes);
List<ContainerTemplate> containers = new ArrayList<ContainerTemplate>();
ContainerTemplate busyboxContainer = new ContainerTemplate("busybox", "busybox");
busyboxContainer.setCommand("cat");
busyboxContainer.setTtyEnabled(true);
List<TemplateEnvVar> envVars = new ArrayList<TemplateEnvVar>();
envVars.add(new KeyValueEnvVar("CONTAINER_ENV_VAR", "container-env-var-value"));
busyboxContainer.setEnvVars(envVars);
busyboxContainer.setRunAsUser("2000");
busyboxContainer.setRunAsGroup("2000");
containers.add(busyboxContainer);
template.setContainers(containers);
setupStubs();
Pod pod = new PodTemplateBuilder(template, slave).build();
pod.getMetadata().setLabels(Collections.singletonMap("some-label", "some-label-value"));
validatePod(pod, false, directConnection);
ArrayList<Long> supplementalGroups = new ArrayList<Long>();
supplementalGroups.add(5001L);
supplementalGroups.add(5002L);
Map<String, Container> containersMap = toContainerMap(pod);
PodSecurityContext securityContext = pod.getSpec().getSecurityContext();
assertEquals(Long.valueOf(1000L), securityContext.getRunAsUser());
assertEquals(Long.valueOf(1000L), securityContext.getRunAsGroup());
assertEquals(supplementalGroups, securityContext.getSupplementalGroups());
assertEquals(Long.valueOf(2000L), containersMap.get("busybox").getSecurityContext().getRunAsUser());
assertEquals(Long.valueOf(2000L), containersMap.get("busybox").getSecurityContext().getRunAsGroup());
}
Aggregations