test deep patch into properties with null value and strict comparison
This commit is contained in:
parent
6ed179951e
commit
ca5cde5f55
@ -1,7 +1,9 @@
|
|||||||
package net.hostsharing.hsadminng.hs.hosting.asset;
|
package net.hostsharing.hsadminng.hs.hosting.asset;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import net.hostsharing.hsadminng.config.JsonObjectMapperConfiguration;
|
import net.hostsharing.hsadminng.config.JsonObjectMapperConfiguration;
|
||||||
import net.hostsharing.hsadminng.context.Context;
|
import net.hostsharing.hsadminng.context.Context;
|
||||||
@ -576,7 +578,6 @@ public class HsHostingAssetControllerRestTest {
|
|||||||
when(emf.createEntityManager(any(Map.class))).thenReturn(em);
|
when(emf.createEntityManager(any(Map.class))).thenReturn(em);
|
||||||
when(emf.createEntityManager(any(SynchronizationType.class))).thenReturn(em);
|
when(emf.createEntityManager(any(SynchronizationType.class))).thenReturn(em);
|
||||||
when(emf.createEntityManager(any(SynchronizationType.class), any(Map.class))).thenReturn(em);
|
when(emf.createEntityManager(any(SynchronizationType.class), any(Map.class))).thenReturn(em);
|
||||||
// doNothing().when(transactionManager).commit(any());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ -645,7 +646,7 @@ public class HsHostingAssetControllerRestTest {
|
|||||||
entry("includes", false),
|
entry("includes", false),
|
||||||
entry("letsencrypt", false),
|
entry("letsencrypt", false),
|
||||||
entry("multiviews", false),
|
entry("multiviews", false),
|
||||||
entry("fcgi-php-bin", "/usr/lib/cgi-bin/php8"),
|
entry("fcgi-php-bin", "/usr/lib/cgi-bin/php-orig"),
|
||||||
entry("passenger-nodejs", "/usr/bin/node-js7"),
|
entry("passenger-nodejs", "/usr/bin/node-js7"),
|
||||||
entry("passenger-python", "/usr/bin/python6"),
|
entry("passenger-python", "/usr/bin/python6"),
|
||||||
entry("passenger-ruby", "/usr/bin/ruby5"),
|
entry("passenger-ruby", "/usr/bin/ruby5"),
|
||||||
@ -671,7 +672,8 @@ public class HsHostingAssetControllerRestTest {
|
|||||||
"autoconfig": true,
|
"autoconfig": true,
|
||||||
"multiviews": true,
|
"multiviews": true,
|
||||||
"passenger": false,
|
"passenger": false,
|
||||||
"fcgi-php-bin": "/usr/lib/cgi-bin/php9",
|
"fcgi-php-bin": null,
|
||||||
|
"passenger-nodejs": "/usr/bin/node-js8",
|
||||||
"subdomains": ["www","test"]
|
"subdomains": ["www","test"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -685,33 +687,46 @@ public class HsHostingAssetControllerRestTest {
|
|||||||
"type": "DOMAIN_HTTP_SETUP",
|
"type": "DOMAIN_HTTP_SETUP",
|
||||||
"identifier": "example.org|HTTP",
|
"identifier": "example.org|HTTP",
|
||||||
"caption": "some updated fake Domain-HTTP-Setup",
|
"caption": "some updated fake Domain-HTTP-Setup",
|
||||||
"alarmContact": null,
|
"alarmContact": null
|
||||||
"config": {
|
|
||||||
"autoconfig": true,
|
|
||||||
"cgi": false,
|
|
||||||
"fastcgi": false,
|
|
||||||
"greylisting": false,
|
|
||||||
"htdocsfallback": false,
|
|
||||||
"includes": false,
|
|
||||||
"indexes": false,
|
|
||||||
"letsencrypt": false,
|
|
||||||
"multiviews": true,
|
|
||||||
"passenger": false,
|
|
||||||
"passenger-errorpage": true,
|
|
||||||
"passenger-nodejs": "/usr/bin/node-js7",
|
|
||||||
"passenger-python": "/usr/bin/python6",
|
|
||||||
"passenger-ruby": "/usr/bin/ruby5",
|
|
||||||
"fcgi-php-bin": "/usr/lib/cgi-bin/php9",
|
|
||||||
"subdomains": ["www","test"]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
""")))
|
""")))
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
// and the config properties do match not just leniently but even strictly
|
// and the config properties do match not just leniently but even strictly
|
||||||
final var resultBody = new ObjectMapper().readTree(result.getResponse().getContentAsString());
|
final var actualConfig = formatJsonNode(result.getResponse().getContentAsString());
|
||||||
for (int n = 0; n < resultBody.size(); ++n) {
|
final var expectedConfig = formatJsonNode("""
|
||||||
// assertThat(resultBody.get(n).path("config")).isEqualTo(testCase.expectedConfig(n));
|
{
|
||||||
}
|
"config": {
|
||||||
|
"autoconfig" : true,
|
||||||
|
"cgi" : false,
|
||||||
|
"fastcgi" : false,
|
||||||
|
// "fcgi-php-bin" : "/usr/lib/cgi-bin/php", TODO.spec: do we want defaults to work like initializers?
|
||||||
|
"greylisting" : false,
|
||||||
|
"htdocsfallback" : false,
|
||||||
|
"includes" : false,
|
||||||
|
"indexes" : false,
|
||||||
|
"letsencrypt" : false,
|
||||||
|
"multiviews" : true,
|
||||||
|
"passenger" : false,
|
||||||
|
"passenger-errorpage" : true,
|
||||||
|
"passenger-nodejs" : "/usr/bin/node-js8",
|
||||||
|
"passenger-python" : "/usr/bin/python6",
|
||||||
|
"passenger-ruby" : "/usr/bin/ruby5",
|
||||||
|
"subdomains" : [ "www", "test" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
""");
|
||||||
|
assertThat(actualConfig).isEqualTo(expectedConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final ObjectMapper SORTED_MAPPER = new ObjectMapper();
|
||||||
|
static {
|
||||||
|
SORTED_MAPPER.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String formatJsonNode(final String json) throws JsonProcessingException {
|
||||||
|
final var node = SORTED_MAPPER.readTree(json.replaceAll("//.*", "")).path("config");
|
||||||
|
final var obj = SORTED_MAPPER.treeToValue(node, Object.class);
|
||||||
|
return SORTED_MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user