align React-GUI and Java API -backend (#188)
Co-authored-by: Michael Hoennig <michael@hoennig.de> Reviewed-on: https://dev.hostsharing.net/hostsharing/hs.hsadmin.ng/pulls/188 Reviewed-by: Timotheus Pokorra <timotheus.pokorra@hostsharing.net>
This commit is contained in:
+2
-1
@@ -14,7 +14,8 @@ class HsCredentialsContextRbacEntityUnitTest {
|
||||
.uuid(UUID.randomUUID())
|
||||
.type("SSH")
|
||||
.qualifier("prod")
|
||||
.publicAccess(true)
|
||||
.build();
|
||||
assertEquals("loginContext(SSH:prod)", entity.toShortString());
|
||||
assertEquals("loginContext(SSH:prod:PUBLIC)", entity.toShortString());
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -77,7 +77,7 @@ class HsCredentialsContextRbacRepositoryIntegrationTest extends ContextBasedTest
|
||||
|
||||
// then
|
||||
assertThat(foundEntityOptional).isPresent();
|
||||
assertThat(foundEntityOptional).map(Object::toString).contains("loginContext(HSADMIN:prod)");
|
||||
assertThat(foundEntityOptional).map(Object::toString).contains("loginContext(HSADMIN:prod:NP-ONLY:PUBLIC)");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -89,7 +89,7 @@ class HsCredentialsContextRbacRepositoryIntegrationTest extends ContextBasedTest
|
||||
|
||||
// then
|
||||
assertThat(foundEntityOptional).isPresent();
|
||||
assertThat(foundEntityOptional).map(Object::toString).contains("loginContext(SSH:internal)");
|
||||
assertThat(foundEntityOptional).map(Object::toString).contains("loginContext(SSH:internal:NP-ONLY:INTERNAL)");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+2
-1
@@ -14,7 +14,8 @@ class HsCredentialsContextRealEntityUnitTest {
|
||||
.uuid(UUID.randomUUID())
|
||||
.type("testType")
|
||||
.qualifier("testQualifier")
|
||||
.onlyForNaturalPersons(true)
|
||||
.build();
|
||||
assertEquals("loginContext(testType:testQualifier)", entity.toShortString());
|
||||
assertEquals("loginContext(testType:testQualifier:NP-ONLY:INTERNAL)", entity.toShortString());
|
||||
}
|
||||
}
|
||||
|
||||
+8
-4
@@ -52,7 +52,9 @@ class HsCredentialsContextRealRepositoryIntegrationTest extends ContextBasedTest
|
||||
final var rowsBefore = query.getResultList();
|
||||
|
||||
// then
|
||||
assertThat(rowsBefore).as("hs_accounts.context_hv only contain no rows for a timestamp before test data creation").hasSize(0);
|
||||
assertThat(rowsBefore)
|
||||
.as("hs_accounts.context_hv only contain no rows for a timestamp before test data creation")
|
||||
.hasSize(0);
|
||||
|
||||
// and when
|
||||
historicalContext(Timestamp.from(ZonedDateTime.now().toInstant()));
|
||||
@@ -60,7 +62,9 @@ class HsCredentialsContextRealRepositoryIntegrationTest extends ContextBasedTest
|
||||
final var rowsAfter = query.getResultList();
|
||||
|
||||
// then
|
||||
assertThat(rowsAfter).as("hs_accounts.context_hv should now contain the test-data rows for the current timestamp").hasSize(4);
|
||||
assertThat(rowsAfter)
|
||||
.as("hs_accounts.context_hv should now contain the test-data rows for the current timestamp")
|
||||
.hasSize(7);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -87,7 +91,7 @@ class HsCredentialsContextRealRepositoryIntegrationTest extends ContextBasedTest
|
||||
|
||||
// then
|
||||
assertThat(foundEntityOptional).isPresent();
|
||||
assertThat(foundEntityOptional).map(Object::toString).contains("loginContext(HSADMIN:prod)");
|
||||
assertThat(foundEntityOptional).map(Object::toString).contains("loginContext(HSADMIN:prod:NP-ONLY:PUBLIC)");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -99,7 +103,7 @@ class HsCredentialsContextRealRepositoryIntegrationTest extends ContextBasedTest
|
||||
|
||||
// then
|
||||
assertThat(foundEntityOptional).isPresent();
|
||||
assertThat(foundEntityOptional).map(Object::toString).contains("loginContext(SSH:internal)");
|
||||
assertThat(foundEntityOptional).map(Object::toString).contains("loginContext(SSH:internal:NP-ONLY:INTERNAL)");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+1
-1
@@ -125,7 +125,7 @@ class HsCredentialsRepositoryIntegrationTest extends ContextBasedTest {
|
||||
assertThat(foundEntity.getGlobalUid()).isEqualTo(2001);
|
||||
|
||||
assertThat(foundEntity.getLoginContexts()).hasSize(1)
|
||||
.map(HsCredentialsContextRealEntity::toString).contains("loginContext(HSADMIN:prod)");
|
||||
.map(HsCredentialsContextRealEntity::toString).contains("loginContext(HSADMIN:prod:NP-ONLY:PUBLIC)");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+1
-1
@@ -117,7 +117,7 @@ class HsOfficePersonEntityUnitTest {
|
||||
|
||||
final var actualDisplay = givenPersonEntity.toString();
|
||||
|
||||
assertThat(actualDisplay).isEqualTo("person(personType='NP', tradeName='some trade name', title='Dr.', familyName='some family name', givenName='some given name')");
|
||||
assertThat(actualDisplay).isEqualTo("person(personType=NP, tradeName='some trade name', title='Dr.', familyName='some family name', givenName='some given name')");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@ class HsOfficeRelationUnitTest {
|
||||
.holder(holder)
|
||||
.build();
|
||||
|
||||
assertThat(given.toString()).isEqualTo("rel(anchor='LP some trade name', type='SUBSCRIBER', mark='members-announce', holder='NP Meier, Mellie')");
|
||||
assertThat(given.toString()).isEqualTo("rel(anchor='LP some trade name', type=SUBSCRIBER, mark='members-announce', holder='NP Meier, Mellie')");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -39,7 +39,7 @@ class HsOfficeRelationUnitTest {
|
||||
.holder(holder)
|
||||
.build();
|
||||
|
||||
assertThat(given.toShortString()).isEqualTo("rel(anchor='LP some trade name', type='REPRESENTATIVE', holder='NP Meier, Mellie')");
|
||||
assertThat(given.toShortString()).isEqualTo("rel(anchor='LP some trade name', type=REPRESENTATIVE, holder='NP Meier, Mellie')");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static net.hostsharing.hsadminng.repr.Symbol.symbol;
|
||||
import static net.hostsharing.hsadminng.repr.Stringify.stringify;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -58,11 +59,12 @@ class StringifyUnitTest {
|
||||
private static Stringify<SubBeanWithUnquotedValues> toString = stringify(SubBeanWithUnquotedValues.class)
|
||||
.withProp(SubBeanWithUnquotedValues::getKey)
|
||||
.withProp(SubBeanWithUnquotedValues::getValue)
|
||||
.withSeparator(": ")
|
||||
.withProp(SubBeanWithUnquotedValues::isActive, v -> v ? symbol("active") : symbol("inactive"))
|
||||
.quotedValues(false);
|
||||
|
||||
private String key;
|
||||
private String value;
|
||||
private boolean active;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
@@ -84,11 +86,13 @@ class StringifyUnitTest {
|
||||
private static Stringify<SubBeanWithQuotedValues> toString = stringify(SubBeanWithQuotedValues.class)
|
||||
.withProp(SubBeanWithQuotedValues::getKey)
|
||||
.withProp(SubBeanWithQuotedValues::getValue)
|
||||
.withProp(SubBeanWithQuotedValues::isActive, v -> v ? "active" : "inactive")
|
||||
.withSeparator(": ")
|
||||
.quotedValues(true);
|
||||
|
||||
private String key;
|
||||
private Integer value;
|
||||
private boolean active;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
@@ -104,8 +108,8 @@ class StringifyUnitTest {
|
||||
@Test
|
||||
void stringifyWhenAllPropsHaveValues() {
|
||||
final var given = new TestBean(UUID.randomUUID(), "some caption",
|
||||
new SubBeanWithUnquotedValues("some key", "some value"),
|
||||
new SubBeanWithQuotedValues("some key", 1234),
|
||||
new SubBeanWithUnquotedValues("some key", "some value", true),
|
||||
new SubBeanWithQuotedValues("some key", 1234, false),
|
||||
42,
|
||||
false);
|
||||
final var result = given.toString();
|
||||
@@ -122,15 +126,15 @@ class StringifyUnitTest {
|
||||
|
||||
@Test
|
||||
void stringifyWithoutExplicitNameUsesSimpleClassName() {
|
||||
final var given = new SubBeanWithUnquotedValues("some key", "some value");
|
||||
final var given = new SubBeanWithUnquotedValues("some key", "some value", false);
|
||||
final var result = given.toString();
|
||||
assertThat(result).isEqualTo("SubBeanWithUnquotedValues(some key: some value)");
|
||||
assertThat(result).isEqualTo("SubBeanWithUnquotedValues(some key, some value, inactive)");
|
||||
}
|
||||
|
||||
@Test
|
||||
void stringifyWithQuotedValueTrueQuotesEvenIntegers() {
|
||||
final var given = new SubBeanWithQuotedValues("some key", 1234);
|
||||
final var given = new SubBeanWithQuotedValues("some key", 1234, true);
|
||||
final var result = given.toString();
|
||||
assertThat(result).isEqualTo("SubBeanWithQuotedValues('some key': '1234')");
|
||||
assertThat(result).isEqualTo("SubBeanWithQuotedValues('some key': '1234': 'active')");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user