|
|
|
@ -16,9 +16,12 @@ |
|
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot.configurationprocessor.test; |
|
|
|
package org.springframework.boot.configurationprocessor.test; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.function.Function; |
|
|
|
|
|
|
|
|
|
|
|
import org.assertj.core.api.AbstractAssert; |
|
|
|
import org.assertj.core.api.AbstractAssert; |
|
|
|
import org.assertj.core.api.AssertProvider; |
|
|
|
import org.assertj.core.api.AssertProvider; |
|
|
|
import org.assertj.core.internal.Objects; |
|
|
|
import org.assertj.core.api.Assertions; |
|
|
|
|
|
|
|
import org.assertj.core.api.ObjectAssert; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.boot.configurationprocessor.metadata.ItemDeprecation; |
|
|
|
import org.springframework.boot.configurationprocessor.metadata.ItemDeprecation; |
|
|
|
import org.springframework.boot.configurationprocessor.metadata.ItemMetadata; |
|
|
|
import org.springframework.boot.configurationprocessor.metadata.ItemMetadata; |
|
|
|
@ -28,34 +31,33 @@ import org.springframework.boot.configurationprocessor.metadata.ItemMetadata.Ite |
|
|
|
* AssertJ assert for {@link ItemMetadata}. |
|
|
|
* AssertJ assert for {@link ItemMetadata}. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Stephane Nicoll |
|
|
|
* @author Stephane Nicoll |
|
|
|
|
|
|
|
* @author Stefano Cordio |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class ItemMetadataAssert extends AbstractAssert<ItemMetadataAssert, ItemMetadata> |
|
|
|
public class ItemMetadataAssert extends AbstractAssert<ItemMetadataAssert, ItemMetadata> |
|
|
|
implements AssertProvider<ItemMetadataAssert> { |
|
|
|
implements AssertProvider<ItemMetadataAssert> { |
|
|
|
|
|
|
|
|
|
|
|
private static final Objects objects = Objects.instance(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ItemMetadataAssert(ItemMetadata itemMetadata) { |
|
|
|
public ItemMetadataAssert(ItemMetadata itemMetadata) { |
|
|
|
super(itemMetadata, ItemMetadataAssert.class); |
|
|
|
super(itemMetadata, ItemMetadataAssert.class); |
|
|
|
objects.assertNotNull(this.info, itemMetadata); |
|
|
|
isNotNull(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ItemMetadataAssert isProperty() { |
|
|
|
public ItemMetadataAssert isProperty() { |
|
|
|
objects.assertEqual(this.info, this.actual.isOfItemType(ItemType.PROPERTY), true); |
|
|
|
extracting((actual) -> actual.isOfItemType(ItemType.PROPERTY)).isEqualTo(true); |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ItemMetadataAssert isGroup() { |
|
|
|
public ItemMetadataAssert isGroup() { |
|
|
|
objects.assertEqual(this.info, this.actual.isOfItemType(ItemType.GROUP), true); |
|
|
|
extracting((actual) -> actual.isOfItemType(ItemType.GROUP)).isEqualTo(true); |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ItemMetadataAssert hasName(String name) { |
|
|
|
public ItemMetadataAssert hasName(String name) { |
|
|
|
objects.assertEqual(this.info, this.actual.getName(), name); |
|
|
|
extracting(ItemMetadata::getName).isEqualTo(name); |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ItemMetadataAssert hasType(String type) { |
|
|
|
public ItemMetadataAssert hasType(String type) { |
|
|
|
objects.assertEqual(this.info, this.actual.getType(), type); |
|
|
|
extracting(ItemMetadata::getType).isEqualTo(type); |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -64,7 +66,7 @@ public class ItemMetadataAssert extends AbstractAssert<ItemMetadataAssert, ItemM |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ItemMetadataAssert hasDescription(String description) { |
|
|
|
public ItemMetadataAssert hasDescription(String description) { |
|
|
|
objects.assertEqual(this.info, this.actual.getDescription(), description); |
|
|
|
extracting(ItemMetadata::getDescription).isEqualTo(description); |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -73,7 +75,7 @@ public class ItemMetadataAssert extends AbstractAssert<ItemMetadataAssert, ItemM |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ItemMetadataAssert hasSourceType(String type) { |
|
|
|
public ItemMetadataAssert hasSourceType(String type) { |
|
|
|
objects.assertEqual(this.info, this.actual.getSourceType(), type); |
|
|
|
extracting(ItemMetadata::getSourceType).isEqualTo(type); |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -82,12 +84,12 @@ public class ItemMetadataAssert extends AbstractAssert<ItemMetadataAssert, ItemM |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ItemMetadataAssert hasSourceMethod(String type) { |
|
|
|
public ItemMetadataAssert hasSourceMethod(String type) { |
|
|
|
objects.assertEqual(this.info, this.actual.getSourceMethod(), type); |
|
|
|
extracting(ItemMetadata::getSourceMethod).isEqualTo(type); |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ItemMetadataAssert hasDefaultValue(Object defaultValue) { |
|
|
|
public ItemMetadataAssert hasDefaultValue(Object defaultValue) { |
|
|
|
objects.assertEqual(this.info, this.actual.getDefaultValue(), defaultValue); |
|
|
|
extracting(ItemMetadata::getDefaultValue).isEqualTo(defaultValue); |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -97,27 +99,28 @@ public class ItemMetadataAssert extends AbstractAssert<ItemMetadataAssert, ItemM |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ItemMetadataAssert isDeprecatedWithReason(String reason) { |
|
|
|
public ItemMetadataAssert isDeprecatedWithReason(String reason) { |
|
|
|
ItemDeprecation deprecation = assertItemDeprecation(); |
|
|
|
assertItemDeprecation().extracting(ItemDeprecation::getReason).isEqualTo(reason); |
|
|
|
objects.assertEqual(this.info, deprecation.getReason(), reason); |
|
|
|
|
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ItemMetadataAssert isDeprecatedWithReplacement(String replacement) { |
|
|
|
public ItemMetadataAssert isDeprecatedWithReplacement(String replacement) { |
|
|
|
ItemDeprecation deprecation = assertItemDeprecation(); |
|
|
|
assertItemDeprecation().extracting(ItemDeprecation::getReplacement).isEqualTo(replacement); |
|
|
|
objects.assertEqual(this.info, deprecation.getReplacement(), replacement); |
|
|
|
|
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ItemMetadataAssert isNotDeprecated() { |
|
|
|
public ItemMetadataAssert isNotDeprecated() { |
|
|
|
objects.assertNull(this.info, this.actual.getDeprecation()); |
|
|
|
extracting(ItemMetadata::getDeprecation).isNull(); |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private ItemDeprecation assertItemDeprecation() { |
|
|
|
private ObjectAssert<ItemDeprecation> assertItemDeprecation() { |
|
|
|
ItemDeprecation deprecation = this.actual.getDeprecation(); |
|
|
|
ObjectAssert<ItemDeprecation> itemDeprecationAssert = extracting(ItemMetadata::getDeprecation); |
|
|
|
objects.assertNotNull(this.info, deprecation); |
|
|
|
itemDeprecationAssert.extracting(ItemDeprecation::getLevel).isNull(); |
|
|
|
objects.assertNull(this.info, deprecation.getLevel()); |
|
|
|
return itemDeprecationAssert; |
|
|
|
return deprecation; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private <T> ObjectAssert<T> extracting(Function<ItemMetadata, T> extractor) { |
|
|
|
|
|
|
|
return super.extracting(extractor, Assertions::assertThat); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
|