Compare commits
No commits in common. "6ddecbbfec18208e7cbd0ba435205921469f1a7a" and "9e04c800d02785389316192c3fe04663712c5deb" have entirely different histories.
6ddecbbfec
...
9e04c800d0
@ -158,8 +158,8 @@ public class HsBookingItemEntity implements Stringifyable, BaseEntity<HsBookingI
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PatchableMapWrapper<Object> directProps() {
|
public Map<String, Object> directProps() {
|
||||||
return getResources();
|
return resources;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -128,8 +128,8 @@ public class HsHostingAssetEntity implements HsHostingAsset {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PatchableMapWrapper<Object> directProps() {
|
public Map<String, Object> directProps() {
|
||||||
return getConfig();
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -14,7 +14,7 @@ public class HsHostingAssetEntityPatcher implements EntityPatcher<HsHostingAsset
|
|||||||
private final EntityManager em;
|
private final EntityManager em;
|
||||||
private final HsHostingAssetEntity entity;
|
private final HsHostingAssetEntity entity;
|
||||||
|
|
||||||
public HsHostingAssetEntityPatcher(final EntityManager em, final HsHostingAssetEntity entity) {
|
HsHostingAssetEntityPatcher(final EntityManager em, final HsHostingAssetEntity entity) {
|
||||||
this.em = em;
|
this.em = em;
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package net.hostsharing.hsadminng.hs.validation;
|
package net.hostsharing.hsadminng.hs.validation;
|
||||||
|
|
||||||
import net.hostsharing.hsadminng.mapper.PatchableMapWrapper;
|
import java.util.Map;
|
||||||
|
|
||||||
public interface PropertiesProvider {
|
public interface PropertiesProvider {
|
||||||
|
|
||||||
boolean isLoaded();
|
boolean isLoaded();
|
||||||
PatchableMapWrapper directProps();
|
Map<String, Object> directProps();
|
||||||
Object getContextValue(final String propName);
|
Object getContextValue(final String propName);
|
||||||
|
|
||||||
default <T> T getDirectValue(final String propName, final Class<T> clazz) {
|
default <T> T getDirectValue(final String propName, final Class<T> clazz) {
|
||||||
@ -16,10 +16,6 @@ public interface PropertiesProvider {
|
|||||||
return cast(propName, directProps().get(propName), clazz, defaultValue);
|
return cast(propName, directProps().get(propName), clazz, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean isPatched(String propertyName) {
|
|
||||||
return directProps().isPatched(propertyName);
|
|
||||||
}
|
|
||||||
|
|
||||||
default <T> T getContextValue(final String propName, final Class<T> clazz) {
|
default <T> T getContextValue(final String propName, final Class<T> clazz) {
|
||||||
return cast(propName, getContextValue(propName), clazz, null);
|
return cast(propName, getContextValue(propName), clazz, null);
|
||||||
}
|
}
|
||||||
|
@ -206,9 +206,6 @@ public abstract class ValidatableProperty<P extends ValidatableProperty<?, ?>, T
|
|||||||
if (required == TRUE) {
|
if (required == TRUE) {
|
||||||
result.add(propertyName + "' is required but missing");
|
result.add(propertyName + "' is required but missing");
|
||||||
}
|
}
|
||||||
if (isWriteOnce() && propsProvider.isLoaded() && propsProvider.isPatched(propertyName) ) {
|
|
||||||
result.add(propertyName + "' is write-once but got removed");
|
|
||||||
}
|
|
||||||
validateRequiresAtLeastOneOf(result, propsProvider);
|
validateRequiresAtLeastOneOf(result, propsProvider);
|
||||||
}
|
}
|
||||||
if (propValue != null){
|
if (propValue != null){
|
||||||
@ -251,12 +248,10 @@ public abstract class ValidatableProperty<P extends ValidatableProperty<?, ?>, T
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void validate(final List<String> result, final T propValue, final PropertiesProvider propProvider) {
|
protected void validate(final List<String> result, final T propValue, final PropertiesProvider propProvider) {
|
||||||
|
|
||||||
if (isReadOnly() && propValue != null) {
|
if (isReadOnly() && propValue != null) {
|
||||||
result.add(propertyName + "' is readonly but given as " + display(propValue));
|
result.add(propertyName + "' is readonly but given as " + display(propValue));
|
||||||
}
|
}
|
||||||
if (isWriteOnce() && propProvider.isLoaded() && propValue != null && propProvider.isPatched(propertyName) ) {
|
|
||||||
result.add(propertyName + "' is write-once but given as " + display(propValue));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void verifyConsistency(final Map.Entry<? extends Enum<?>, ?> typeDef) {
|
public void verifyConsistency(final Map.Entry<? extends Enum<?>, ?> typeDef) {
|
||||||
|
@ -7,9 +7,7 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
|
|||||||
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
@ -25,7 +23,6 @@ public class PatchableMapWrapper<T> implements Map<String, T> {
|
|||||||
.configure(SerializationFeature.INDENT_OUTPUT, true);
|
.configure(SerializationFeature.INDENT_OUTPUT, true);
|
||||||
|
|
||||||
private final Map<String, T> delegate;
|
private final Map<String, T> delegate;
|
||||||
private final Set<String> patched = new HashSet<>();
|
|
||||||
|
|
||||||
private PatchableMapWrapper(final Map<String, T> map) {
|
private PatchableMapWrapper(final Map<String, T> map) {
|
||||||
delegate = map;
|
delegate = map;
|
||||||
@ -39,10 +36,6 @@ public class PatchableMapWrapper<T> implements Map<String, T> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> PatchableMapWrapper<T> of(final Map<String, T> delegate) {
|
|
||||||
return new PatchableMapWrapper<T>(delegate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static <E> ImmutablePair<String, E> entry(final String key, final E value) {
|
public static <E> ImmutablePair<String, E> entry(final String key, final E value) {
|
||||||
return new ImmutablePair<>(key, value);
|
return new ImmutablePair<>(key, value);
|
||||||
@ -52,7 +45,6 @@ public class PatchableMapWrapper<T> implements Map<String, T> {
|
|||||||
if (entries != null ) {
|
if (entries != null ) {
|
||||||
delegate.clear();
|
delegate.clear();
|
||||||
delegate.putAll(entries);
|
delegate.putAll(entries);
|
||||||
patched.clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,10 +58,6 @@ public class PatchableMapWrapper<T> implements Map<String, T> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPatched(final String propertyName) {
|
|
||||||
return patched.contains(propertyName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return jsonWriter.writeValueAsString(delegate);
|
return jsonWriter.writeValueAsString(delegate);
|
||||||
@ -104,17 +92,11 @@ public class PatchableMapWrapper<T> implements Map<String, T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T put(final String key, final T value) {
|
public T put(final String key, final T value) {
|
||||||
if (!Objects.equals(value, delegate.get(key))) {
|
|
||||||
patched.add(key);
|
|
||||||
}
|
|
||||||
return delegate.put(key, value);
|
return delegate.put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T remove(final Object key) {
|
public T remove(final Object key) {
|
||||||
if (delegate.containsKey(key.toString())) {
|
|
||||||
patched.add(key.toString());
|
|
||||||
}
|
|
||||||
return delegate.remove(key);
|
return delegate.remove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,24 +107,20 @@ public class PatchableMapWrapper<T> implements Map<String, T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
patched.addAll(delegate.keySet());
|
|
||||||
delegate.clear();
|
delegate.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
|
||||||
public Set<String> keySet() {
|
public Set<String> keySet() {
|
||||||
return delegate.keySet();
|
return delegate.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
|
||||||
public Collection<T> values() {
|
public Collection<T> values() {
|
||||||
return delegate.values();
|
return delegate.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
|
||||||
public Set<Entry<String, T>> entrySet() {
|
public Set<Entry<String, T>> entrySet() {
|
||||||
return delegate.entrySet();
|
return delegate.entrySet();
|
||||||
}
|
}
|
||||||
|
@ -588,7 +588,7 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup
|
|||||||
}).returnedValue()).isPresent().get()
|
}).returnedValue()).isPresent().get()
|
||||||
.matches(asset -> {
|
.matches(asset -> {
|
||||||
assertThat(asset.getCaption()).isEqualTo("some patched test-unix-user");
|
assertThat(asset.getCaption()).isEqualTo("some patched test-unix-user");
|
||||||
assertThat(asset.getConfig().toString()).isEqualToIgnoringWhitespace("""
|
assertThat(asset.getConfig().toString()).isEqualTo("""
|
||||||
{
|
{
|
||||||
"password": "$6$Jr5w/Y8zo8pCkqg7$/rePRbvey3R6Sz/02YTlTQcRt5qdBPTj2h5.hz.rB8NfIoND8pFOjeB7orYcPs9JNf3JDxPP2V.6MQlE5BwAY/",
|
"password": "$6$Jr5w/Y8zo8pCkqg7$/rePRbvey3R6Sz/02YTlTQcRt5qdBPTj2h5.hz.rB8NfIoND8pFOjeB7orYcPs9JNf3JDxPP2V.6MQlE5BwAY/",
|
||||||
"shell": "/bin/bash",
|
"shell": "/bin/bash",
|
||||||
|
@ -444,7 +444,6 @@ class HsHostingAssetRepositoryIntegrationTest extends ContextBasedTestWithCleanu
|
|||||||
.extracting(HsHostingAssetEntity::toString)
|
.extracting(HsHostingAssetEntity::toString)
|
||||||
.extracting(input -> input.replaceAll("\\s+", " "))
|
.extracting(input -> input.replaceAll("\\s+", " "))
|
||||||
.extracting(input -> input.replaceAll("\"", ""))
|
.extracting(input -> input.replaceAll("\"", ""))
|
||||||
.extracting(input -> input.replaceAll("\" : ", "\": "))
|
|
||||||
.containsExactlyInAnyOrder(serverNames);
|
.containsExactlyInAnyOrder(serverNames);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,15 +4,13 @@ import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetEntity;
|
|||||||
import net.hostsharing.hsadminng.mapper.Array;
|
import net.hostsharing.hsadminng.mapper.Array;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static java.util.Map.ofEntries;
|
import static java.util.Map.entry;
|
||||||
import static net.hostsharing.hsadminng.hs.booking.item.TestHsBookingItem.TEST_MANAGED_SERVER_BOOKING_ITEM;
|
import static net.hostsharing.hsadminng.hs.booking.item.TestHsBookingItem.TEST_MANAGED_SERVER_BOOKING_ITEM;
|
||||||
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.DOMAIN_MBOX_SETUP;
|
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.DOMAIN_MBOX_SETUP;
|
||||||
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.EMAIL_ADDRESS;
|
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.EMAIL_ADDRESS;
|
||||||
import static net.hostsharing.hsadminng.hs.hosting.asset.TestHsHostingAssetEntities.TEST_MANAGED_SERVER_HOSTING_ASSET;
|
import static net.hostsharing.hsadminng.hs.hosting.asset.TestHsHostingAssetEntities.TEST_MANAGED_SERVER_HOSTING_ASSET;
|
||||||
import static net.hostsharing.hsadminng.mapper.PatchableMapWrapper.entry;
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
class HsEMailAddressHostingAssetValidatorUnitTest {
|
class HsEMailAddressHostingAssetValidatorUnitTest {
|
||||||
@ -30,11 +28,11 @@ class HsEMailAddressHostingAssetValidatorUnitTest {
|
|||||||
return HsHostingAssetEntity.builder()
|
return HsHostingAssetEntity.builder()
|
||||||
.type(EMAIL_ADDRESS)
|
.type(EMAIL_ADDRESS)
|
||||||
.parentAsset(domainMboxSetup)
|
.parentAsset(domainMboxSetup)
|
||||||
.identifier("old-local-part@example.org")
|
.identifier("test@example.org")
|
||||||
.config(new HashMap<>(ofEntries(
|
.config(Map.ofEntries(
|
||||||
entry("local-part", "old-local-part"),
|
entry("local-part", "test"),
|
||||||
entry("target", Array.of("xyz00", "xyz00-abc", "office@example.com"))
|
entry("target", Array.of("xyz00", "xyz00-abc", "office@example.com"))
|
||||||
)));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -66,10 +64,10 @@ class HsEMailAddressHostingAssetValidatorUnitTest {
|
|||||||
void rejectsInvalidProperties() {
|
void rejectsInvalidProperties() {
|
||||||
// given
|
// given
|
||||||
final var emailAddressHostingAssetEntity = validEntityBuilder()
|
final var emailAddressHostingAssetEntity = validEntityBuilder()
|
||||||
.config(new HashMap<>(ofEntries(
|
.config(Map.ofEntries(
|
||||||
entry("local-part", "no@allowed"),
|
entry("local-part", "no@allowed"),
|
||||||
entry("sub-domain", "no@allowedeither"),
|
entry("sub-domain", "no@allowedeither"),
|
||||||
entry("target", Array.of("xyz00", "xyz00-abc", "garbage", "office@example.com")))))
|
entry("target", Array.of("xyz00", "xyz00-abc", "garbage", "office@example.com"))))
|
||||||
.build();
|
.build();
|
||||||
final var validator = HostingAssetEntityValidatorRegistry.forType(emailAddressHostingAssetEntity.getType());
|
final var validator = HostingAssetEntityValidatorRegistry.forType(emailAddressHostingAssetEntity.getType());
|
||||||
|
|
||||||
@ -78,69 +76,9 @@ class HsEMailAddressHostingAssetValidatorUnitTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result).containsExactlyInAnyOrder(
|
assertThat(result).containsExactlyInAnyOrder(
|
||||||
"'EMAIL_ADDRESS:old-local-part@example.org.config.local-part' is expected to match any of [^[a-zA-Z0-9_!#$%&'*+/=?`{|}~^.-]+$] but 'no@allowed' does not match",
|
"'EMAIL_ADDRESS:test@example.org.config.local-part' is expected to match any of [^[a-zA-Z0-9_!#$%&'*+/=?`{|}~^.-]+$] but 'no@allowed' does not match",
|
||||||
"'EMAIL_ADDRESS:old-local-part@example.org.config.sub-domain' is expected to match any of [^[a-zA-Z0-9_!#$%&'*+/=?`{|}~^.-]+$] but 'no@allowedeither' does not match",
|
"'EMAIL_ADDRESS:test@example.org.config.sub-domain' is expected to match any of [^[a-zA-Z0-9_!#$%&'*+/=?`{|}~^.-]+$] but 'no@allowedeither' does not match",
|
||||||
"'EMAIL_ADDRESS:old-local-part@example.org.config.target' is expected to match any of [^[a-z][a-z0-9]{2}[0-9]{2}(-[a-z0-9][a-z0-9\\._-]*)?$, ^([a-zA-Z0-9_!#$%&'*+/=?`{|}~^.-]+)?@[a-zA-Z0-9.-]+$, ^nobody$] but 'garbage' does not match any");
|
"'EMAIL_ADDRESS:test@example.org.config.target' is expected to match any of [^[a-z][a-z0-9]{2}[0-9]{2}(-[a-z0-9][a-z0-9\\._-]*)?$, ^([a-zA-Z0-9_!#$%&'*+/=?`{|}~^.-]+)?@[a-zA-Z0-9.-]+$, ^nobody$] but 'garbage' does not match any");
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void rejectsOverwritingWriteOnceProperties() {
|
|
||||||
// given
|
|
||||||
final var emailAddressHostingAssetEntity = validEntityBuilder()
|
|
||||||
.isLoaded(true)
|
|
||||||
.build();
|
|
||||||
final var validator = HostingAssetEntityValidatorRegistry.forType(emailAddressHostingAssetEntity.getType());
|
|
||||||
|
|
||||||
// when
|
|
||||||
emailAddressHostingAssetEntity.getConfig().put("local-part", "new-local-part");
|
|
||||||
emailAddressHostingAssetEntity.getConfig().put("sub-domain", "new-sub-domain");
|
|
||||||
final var result = validator.validateEntity(emailAddressHostingAssetEntity);
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertThat(result).containsExactlyInAnyOrder(
|
|
||||||
"'EMAIL_ADDRESS:old-local-part@example.org.config.local-part' is write-once but given as 'new-local-part'",
|
|
||||||
"'EMAIL_ADDRESS:old-local-part@example.org.config.sub-domain' is write-once but given as 'new-sub-domain'");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void rejectsRemovingWriteOnceProperties() {
|
|
||||||
// given
|
|
||||||
final var emailAddressHostingAssetEntity = validEntityBuilder()
|
|
||||||
.config(new HashMap<>(ofEntries(
|
|
||||||
entry("local-part", "old-local-part"),
|
|
||||||
entry("sub-domain", "old-sub-domain"),
|
|
||||||
entry("target", Array.of("xyz00", "xyz00-abc", "office@example.com"))
|
|
||||||
)))
|
|
||||||
.isLoaded(true)
|
|
||||||
.build();
|
|
||||||
final var validator = HostingAssetEntityValidatorRegistry.forType(emailAddressHostingAssetEntity.getType());
|
|
||||||
|
|
||||||
// when
|
|
||||||
emailAddressHostingAssetEntity.getConfig().remove("local-part");
|
|
||||||
emailAddressHostingAssetEntity.getConfig().remove("sub-domain");
|
|
||||||
final var result = validator.validateEntity(emailAddressHostingAssetEntity);
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertThat(result).containsExactlyInAnyOrder(
|
|
||||||
"'EMAIL_ADDRESS:old-local-part@example.org.config.local-part' is write-once but got removed",
|
|
||||||
"'EMAIL_ADDRESS:old-local-part@example.org.config.sub-domain' is write-once but got removed");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void acceptsOverwritingWriteOncePropertiesWithSameValues() {
|
|
||||||
// given
|
|
||||||
final var emailAddressHostingAssetEntity = validEntityBuilder()
|
|
||||||
.isLoaded(true)
|
|
||||||
.build();
|
|
||||||
final var validator = HostingAssetEntityValidatorRegistry.forType(emailAddressHostingAssetEntity.getType());
|
|
||||||
|
|
||||||
// when
|
|
||||||
emailAddressHostingAssetEntity.getConfig().put("local-part", "old-local-part");
|
|
||||||
emailAddressHostingAssetEntity.getConfig().remove("sub-domain"); // is not there anyway
|
|
||||||
final var result = validator.validateEntity(emailAddressHostingAssetEntity);
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertThat(result).isEmpty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -156,7 +94,7 @@ class HsEMailAddressHostingAssetValidatorUnitTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result).containsExactlyInAnyOrder(
|
assertThat(result).containsExactlyInAnyOrder(
|
||||||
"'identifier' expected to match '^\\Qold-local-part@example.org\\E$', but is 'abc00-office'");
|
"'identifier' expected to match '^\\Qtest@example.org\\E$', but is 'abc00-office'");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -174,8 +112,8 @@ class HsEMailAddressHostingAssetValidatorUnitTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result).containsExactlyInAnyOrder(
|
assertThat(result).containsExactlyInAnyOrder(
|
||||||
"'EMAIL_ADDRESS:old-local-part@example.org.bookingItem' must be null but is of type MANAGED_SERVER",
|
"'EMAIL_ADDRESS:test@example.org.bookingItem' must be null but is of type MANAGED_SERVER",
|
||||||
"'EMAIL_ADDRESS:old-local-part@example.org.parentAsset' must be of type DOMAIN_MBOX_SETUP but is of type MANAGED_SERVER",
|
"'EMAIL_ADDRESS:test@example.org.parentAsset' must be of type DOMAIN_MBOX_SETUP but is of type MANAGED_SERVER",
|
||||||
"'EMAIL_ADDRESS:old-local-part@example.org.assignedToAsset' must be null but is of type MANAGED_SERVER");
|
"'EMAIL_ADDRESS:test@example.org.assignedToAsset' must be null but is of type MANAGED_SERVER");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,8 +103,8 @@ public class HsHostingAssetRealEntity implements HsHostingAsset {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PatchableMapWrapper<Object> directProps() {
|
public Map<String, Object> directProps() {
|
||||||
return getConfig();
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -652,12 +652,14 @@ public class ImportHostingAssets extends ImportOfficeData {
|
|||||||
|
|
||||||
void validateHostingAssets(final Map<Integer, HsHostingAssetRealEntity> assets) {
|
void validateHostingAssets(final Map<Integer, HsHostingAssetRealEntity> assets) {
|
||||||
assets.forEach((id, ha) -> {
|
assets.forEach((id, ha) -> {
|
||||||
logError(() ->
|
try {
|
||||||
new HostingAssetEntitySaveProcessor(em, ha)
|
new HostingAssetEntitySaveProcessor(em, ha)
|
||||||
.preprocessEntity()
|
.preprocessEntity()
|
||||||
.validateEntity()
|
.validateEntity()
|
||||||
.prepareForSave()
|
.prepareForSave();
|
||||||
);
|
} catch (final Exception exc) {
|
||||||
|
errors.add("validation failed for id:" + id + "( " + ha + "): " + exc.getMessage());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,15 +134,6 @@ public class ImportOfficeData extends CsvDataImport {
|
|||||||
static Map<Integer, HsOfficeCoopSharesTransactionEntity> coopShares = new WriteOnceMap<>();
|
static Map<Integer, HsOfficeCoopSharesTransactionEntity> coopShares = new WriteOnceMap<>();
|
||||||
static Map<Integer, HsOfficeCoopAssetsTransactionEntity> coopAssets = new WriteOnceMap<>();
|
static Map<Integer, HsOfficeCoopAssetsTransactionEntity> coopAssets = new WriteOnceMap<>();
|
||||||
|
|
||||||
@Test
|
|
||||||
@Order(1)
|
|
||||||
void verifyInitialDatabase() {
|
|
||||||
// SQL DELETE for thousands of records takes too long, so we make sure, we only start with initial or test data
|
|
||||||
final var contactCount = (Integer) em.createNativeQuery("select count(*) from hs_office_contact", Integer.class)
|
|
||||||
.getSingleResult();
|
|
||||||
assertThat(contactCount).isLessThan(20);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(1010)
|
@Order(1010)
|
||||||
void importBusinessPartners() {
|
void importBusinessPartners() {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package net.hostsharing.hsadminng.hs.validation;
|
package net.hostsharing.hsadminng.hs.validation;
|
||||||
|
|
||||||
import net.hostsharing.hsadminng.hash.LinuxEtcShadowHashGenerator;
|
import net.hostsharing.hsadminng.hash.LinuxEtcShadowHashGenerator;
|
||||||
import net.hostsharing.hsadminng.mapper.PatchableMapWrapper;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.ValueSource;
|
import org.junit.jupiter.params.provider.ValueSource;
|
||||||
@ -110,10 +109,10 @@ class PasswordPropertyUnitTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PatchableMapWrapper<Object> directProps() {
|
public Map<String, Object> directProps() {
|
||||||
return PatchableMapWrapper.of(Map.ofEntries(
|
return Map.ofEntries(
|
||||||
entry(passwordProp.propertyName, "some password")
|
entry(passwordProp.propertyName, "some password")
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -34,7 +34,7 @@ public abstract class PatchUnitTestBase<R, E> {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected void willPatchAllProperties() {
|
void willPatchAllProperties() {
|
||||||
// given
|
// given
|
||||||
final var givenEntity = newInitialEntity();
|
final var givenEntity = newInitialEntity();
|
||||||
final var patchResource = newPatchResource();
|
final var patchResource = newPatchResource();
|
||||||
@ -55,7 +55,7 @@ public abstract class PatchUnitTestBase<R, E> {
|
|||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@MethodSource("propertyTestCases")
|
@MethodSource("propertyTestCases")
|
||||||
protected void willPatchOnlyGivenProperty(final Property<R, Object, E, Object> testCase) {
|
void willPatchOnlyGivenProperty(final Property<R, Object, E, Object> testCase) {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
final var givenEntity = newInitialEntity();
|
final var givenEntity = newInitialEntity();
|
||||||
|
Loading…
Reference in New Issue
Block a user