Search in sources :

Example 11 with TestCaseName

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));
}
Also used : Response(org.folio.rest.support.Response) JsonObject(io.vertx.core.json.JsonObject) IndividualResource(org.folio.rest.support.IndividualResource) Parameters(junitparams.Parameters) Test(org.junit.Test) TestCaseName(junitparams.naming.TestCaseName)

Example 12 with TestCaseName

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);
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) JsonNode(com.fasterxml.jackson.databind.JsonNode) URI(java.net.URI) Parameters(junitparams.Parameters) Test(org.junit.Test) TestCaseName(junitparams.naming.TestCaseName)

Example 13 with TestCaseName

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));
}
Also used : SchemaCleanUpUtils(com.github.victools.jsonschema.generator.impl.SchemaCleanUpUtils) Parameters(junitparams.Parameters) Test(org.junit.Test) TestCaseName(junitparams.naming.TestCaseName)

Example 14 with TestCaseName

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);
}
Also used : FieldScope(com.github.victools.jsonschema.generator.FieldScope) ConfigFunction(com.github.victools.jsonschema.generator.ConfigFunction) Parameters(junitparams.Parameters) Test(org.junit.Test) TestCaseName(junitparams.naming.TestCaseName)

Example 15 with TestCaseName

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());
}
Also used : TemplateEnvVar(org.csanchez.jenkins.plugins.kubernetes.model.TemplateEnvVar) PodTemplateBuilder(org.csanchez.jenkins.plugins.kubernetes.PodTemplateBuilder) Pod(io.fabric8.kubernetes.api.model.Pod) PodSecurityContext(io.fabric8.kubernetes.api.model.PodSecurityContext) HostPathVolume(org.csanchez.jenkins.plugins.kubernetes.volumes.HostPathVolume) KeyValueEnvVar(org.csanchez.jenkins.plugins.kubernetes.model.KeyValueEnvVar) ArrayList(java.util.ArrayList) Container(io.fabric8.kubernetes.api.model.Container) EmptyDirVolume(org.csanchez.jenkins.plugins.kubernetes.volumes.EmptyDirVolume) PodVolume(org.csanchez.jenkins.plugins.kubernetes.volumes.PodVolume) Parameters(junitparams.Parameters) Test(org.junit.Test) TestCaseName(junitparams.naming.TestCaseName)

Aggregations

Parameters (junitparams.Parameters)16 TestCaseName (junitparams.naming.TestCaseName)16 Test (org.junit.Test)16 Container (io.fabric8.kubernetes.api.model.Container)7 Pod (io.fabric8.kubernetes.api.model.Pod)7 PodTemplateBuilder (org.csanchez.jenkins.plugins.kubernetes.PodTemplateBuilder)7 FieldScope (com.github.victools.jsonschema.generator.FieldScope)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 AbstractTypeAwareTest (com.github.victools.jsonschema.generator.AbstractTypeAwareTest)2 ConfigFunction (com.github.victools.jsonschema.generator.ConfigFunction)2 JsonObject (io.vertx.core.json.JsonObject)2 IndividualResource (org.folio.rest.support.IndividualResource)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 MethodScope (com.github.victools.jsonschema.generator.MethodScope)1 SchemaCleanUpUtils (com.github.victools.jsonschema.generator.impl.SchemaCleanUpUtils)1 PodSecurityContext (io.fabric8.kubernetes.api.model.PodSecurityContext)1 Quantity (io.fabric8.kubernetes.api.model.Quantity)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 KeyValueEnvVar (org.csanchez.jenkins.plugins.kubernetes.model.KeyValueEnvVar)1