Search in sources :

Example 1 with TestCaseName

use of junitparams.naming.TestCaseName in project mod-inventory-storage by folio-org.

the class ItemEffectiveCallNumberComponentsTest method canCalculateEffectiveCallNumberPropertyOnUpdate.

@Test
@Parameters(source = ItemEffectiveCallNumberComponentsTestData.class, method = "updatePropertiesParams")
@TestCaseName("[{index}]: {params}")
public void canCalculateEffectiveCallNumberPropertyOnUpdate(CallNumberComponentPropertyNames callNumberProperties, String holdingsInitValue, String holdingsTargetValue, String itemInitValue, String itemTargetValue) {
    final String holdingsPropertyName = callNumberProperties.holdingsPropertyName;
    final String itemPropertyName = callNumberProperties.itemPropertyName;
    final String effectivePropertyName = callNumberProperties.effectivePropertyName;
    final String initEffectiveValue = StringUtils.firstNonBlank(itemInitValue, holdingsInitValue);
    final String targetEffectiveValue = StringUtils.firstNonBlank(itemTargetValue, holdingsTargetValue);
    IndividualResource holdings = createHoldingsWithPropertySetAndInstance(holdingsPropertyName, holdingsInitValue);
    IndividualResource createdItem = itemsClient.create(nodWithNoBarcode(holdings.getId()).put(itemPropertyName, itemInitValue));
    JsonObject effectiveCallNumberComponents = createdItem.getJson().getJsonObject("effectiveCallNumberComponents");
    assertNotNull(effectiveCallNumberComponents);
    assertThat(effectiveCallNumberComponents.getString(effectivePropertyName), is(initEffectiveValue));
    holdingsClient.replace(holdings.getId(), getHoldingsById(holdings.getJson()).put(holdingsPropertyName, holdingsTargetValue));
    var itemAfterHoldingsUpdate = getById(createdItem.getJson());
    assertUpdateEventForItem(createdItem.getJson(), itemAfterHoldingsUpdate);
    if (!Objects.equals(itemInitValue, itemTargetValue)) {
        itemsClient.replace(createdItem.getId(), itemAfterHoldingsUpdate.copy().put(itemPropertyName, itemTargetValue));
        await().untilAsserted(() -> {
            var instanceId = holdings.getJson().getString("instanceId");
            var itemId = createdItem.getId().toString();
            var lastItemEvent = getLastItemEvent(instanceId, itemId);
            assertTrue(lastItemEvent.value().getJsonObject("new").getInteger("_version") > 1);
            assertUpdateEventForItem(itemAfterHoldingsUpdate, itemsClient.getById(createdItem.getId()).getJson());
        });
    }
    final JsonObject updatedItem = itemsClient.getById(createdItem.getId()).getJson();
    final JsonObject updatedEffectiveCallNumberComponents = updatedItem.getJsonObject("effectiveCallNumberComponents");
    assertNotNull(updatedEffectiveCallNumberComponents);
    assertThat(updatedEffectiveCallNumberComponents.getString(effectivePropertyName), is(targetEffectiveValue));
}
Also used : JsonObject(io.vertx.core.json.JsonObject) IndividualResource(org.folio.rest.support.IndividualResource) Parameters(junitparams.Parameters) Test(org.junit.Test) TestCaseName(junitparams.naming.TestCaseName)

Example 2 with TestCaseName

use of junitparams.naming.TestCaseName in project jsonschema-generator by victools.

the class SchemaGeneratorSubtypesTest method testGenerateSchema.

@Test
@Parameters
@TestCaseName(value = "{method}({0}) [{index}]")
public void testGenerateSchema(String caseTitle, List<Class<?>> subtypes, SchemaVersion schemaVersion) throws Exception {
    SchemaGeneratorConfigBuilder configBuilder = new SchemaGeneratorConfigBuilder(schemaVersion, OptionPreset.PLAIN_JSON).with(Option.DEFINITIONS_FOR_ALL_OBJECTS, Option.NULLABLE_FIELDS_BY_DEFAULT);
    configBuilder.forTypesInGeneral().withSubtypeResolver(new TestSubtypeResolver(subtypes)).withTitleResolver(TypeScope::getSimpleTypeDescription).withDescriptionResolver(scope -> scope.getType().getErasedType() == TestSuperClass.class ? "supertype-only description" : null);
    if (!subtypes.isEmpty()) {
        configBuilder.forFields().withTargetTypeOverridesResolver(this::determineTargetTypeOverrides);
    }
    SchemaGenerator generator = new SchemaGenerator(configBuilder.build());
    JsonNode result = generator.generateSchema(TestClassWithSuperTypeReferences.class);
    JSONAssert.assertEquals('\n' + result.toString() + '\n', TestUtils.loadResource(SchemaGeneratorSubtypesTest.class, caseTitle + ".json"), result.toString(), JSONCompareMode.STRICT);
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) Parameters(junitparams.Parameters) Test(org.junit.Test) TestCaseName(junitparams.naming.TestCaseName)

Example 3 with TestCaseName

use of junitparams.naming.TestCaseName in project jsonschema-generator by victools.

the class FieldExclusionModuleTest method testIgnoreCheck.

@Test
@Parameters
@TestCaseName("{method}({1}: {0} => {2}) [{index}]")
public void testIgnoreCheck(String testFieldName, String supplierMethodName, boolean ignored) throws Exception {
    FieldExclusionModule moduleInstance = (FieldExclusionModule) FieldExclusionModule.class.getMethod(supplierMethodName).invoke(null);
    moduleInstance.applyToConfigBuilder(this.builder);
    FieldScope field = this.getTestClassField(testFieldName);
    Assert.assertEquals(ignored, this.fieldConfigPart.shouldIgnore(field));
}
Also used : FieldScope(com.github.victools.jsonschema.generator.FieldScope) Parameters(junitparams.Parameters) Test(org.junit.Test) AbstractTypeAwareTest(com.github.victools.jsonschema.generator.AbstractTypeAwareTest) TestCaseName(junitparams.naming.TestCaseName)

Example 4 with TestCaseName

use of junitparams.naming.TestCaseName in project jsonschema-generator by victools.

the class MethodExclusionModuleTest method testIgnoreCheck.

@Test
@Parameters
@TestCaseName("{method}({1}: {0} => {2}) [{index}]")
public void testIgnoreCheck(String testMethodName, String supplierMethodName, boolean ignored) throws Exception {
    MethodExclusionModule moduleInstance = (MethodExclusionModule) MethodExclusionModule.class.getMethod(supplierMethodName).invoke(null);
    moduleInstance.applyToConfigBuilder(this.builder);
    MethodScope method = this.getTestClassMethod(testMethodName);
    Assert.assertEquals(ignored, this.methodConfigPart.shouldIgnore(method));
}
Also used : MethodScope(com.github.victools.jsonschema.generator.MethodScope) Parameters(junitparams.Parameters) Test(org.junit.Test) AbstractTypeAwareTest(com.github.victools.jsonschema.generator.AbstractTypeAwareTest) TestCaseName(junitparams.naming.TestCaseName)

Example 5 with TestCaseName

use of junitparams.naming.TestCaseName in project jsonschema-generator by victools.

the class JakartaValidationModuleTest method testValidationGroupSetting.

@Test
@Parameters
@TestCaseName("{method}({0}, {1}, {2}) [{index}]")
public void testValidationGroupSetting(String testCase, String fieldName, Boolean expectedResult, Class<?>[] validationGroups) {
    JakartaValidationModule module = new JakartaValidationModule();
    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)

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