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));
}
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);
}
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));
}
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));
}
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);
}
Aggregations