Skip to content
Snippets Groups Projects
Commit fee628b7 authored by OZGCloud's avatar OZGCloud
Browse files

Merge branch 'master' into OZG-1274

parents 200297f6 b6c36d5c
No related branches found
No related tags found
No related merge requests found
Showing
with 97 additions and 38 deletions
import { registerLocaleData } from '@angular/common';
import localeDe from '@angular/common/locales/de';
import { format } from 'date-fns';
import { de } from 'date-fns/locale';
import { formatForDatabase, formatFullDate, formatFullDateWithTimeAndDay, formatFullDateWithTimeWithoutSeconds, formatToPrettyDate, formatWithoutYear } from './date.util';
registerLocaleData(localeDe);
......@@ -43,8 +45,8 @@ describe('Date Util', () => {
describe('formatToPrettyDate()', () => {
it('should format date without year', () => {
const today: Date = new Date();
const day: number = today.getDate();
const month: string = today.toLocaleString('de', { month: 'short' });
const day: string = format(today, 'dd');
const month: string = format(today, 'MMMM', {locale: de});
const result: string = formatToPrettyDate(today);
......
......@@ -25,5 +25,5 @@ public @interface BinaryFileMaxSizeConstraint {
int max() default UploadBinaryFileSizeValidator.DEFAULT_MAX_SIZE;
String unit() default UploadBinaryFileSizeValidator.DEFAULT_UNIT;
String unit() default UploadBinaryFileSizeValidator.DEFAULT_UNIT_STRING;
}
\ No newline at end of file
package de.itvsh.goofy.common.binaryfile;
class BinaryFileUnit {// NOSONAR
static final String MB = "MB";
}
\ No newline at end of file
......@@ -13,10 +13,12 @@ import org.springframework.util.unit.DataUnit;
class UploadBinaryFileSizeValidator implements ConstraintValidator<BinaryFileMaxSizeConstraint, UploadBinaryFileRequest> {
static final String DEFAULT_UNIT = BinaryFileUnit.MB;
static final String DEFAULT_UNIT_STRING = "MB";
static final DataUnit DEFAULT_UNIT = DataUnit.fromSuffix(DEFAULT_UNIT_STRING);
static final int DEFAULT_MAX_SIZE = 40;
private final DataSize defaultDataSize = DataSize.of(DEFAULT_MAX_SIZE, DataUnit.fromSuffix(DEFAULT_UNIT));
private final DataSize defaultDataSize = DataSize.of(DEFAULT_MAX_SIZE, DEFAULT_UNIT);
@Autowired
private BinaryFileProperties binaryFileProperties;
......
......@@ -4,9 +4,11 @@ import java.util.Map;
import lombok.Builder;
import lombok.Getter;
import lombok.ToString;
@Getter
@Builder
@ToString
public class Eingang {
private String id;
......@@ -18,6 +20,6 @@ public class Eingang {
private Antragsteller antragsteller;
private EingangHeader header;
@ToString.Exclude
private Map<String, Object> formData;
}
......@@ -42,6 +42,5 @@ class VorgangHeader implements Vorgang {
@JsonProperty(access = Access.READ_ONLY)
private LocalDate nextFrist;
@Builder.Default
private boolean hasPostfachNachricht = true;
private boolean hasPostfachNachricht;
}
......@@ -2,6 +2,7 @@ package de.itvsh.goofy.vorgang;
import java.time.LocalDate;
import java.util.List;
import java.util.stream.Stream;
import org.apache.commons.lang3.StringUtils;
import org.mapstruct.CollectionMappingStrategy;
......@@ -18,19 +19,27 @@ import de.itvsh.ozg.pluto.vorgang.GrpcVorgangHeader;
interface VorgangHeaderMapper {
static final String WIEDERVORLAGE_NEXT_FRIST_ATTRIBUTE_NAME = "nextWiedervorlageFrist";
static final String HAS_POSTFACH_NACHRICHT_ATTRIBUTE_NAME = "hasPostfachNachricht";
@Mapping(target = "nextFrist", source = "clientAttributesList")
@Mapping(target = "hasPostfachNachricht", source = "clientAttributesList")
VorgangHeader toVorgangHeader(GrpcVorgangHeader vorgangHeader);
default LocalDate mapNextFrist(List<GrpcClientAttribute> clientAttributes) {
var clientAttributeList = clientAttributes.stream()
.filter(attribute -> StringUtils.equals(attribute.getAttributeName(), WIEDERVORLAGE_NEXT_FRIST_ATTRIBUTE_NAME))
.map(GrpcClientAttribute::getValue)
return findByName(WIEDERVORLAGE_NEXT_FRIST_ATTRIBUTE_NAME, clientAttributes)
.map(GrpcClientAttributeValue::getStringValue)
.map(LocalDate::parse).toList();
if (clientAttributeList.isEmpty()) {
return null;
.map(LocalDate::parse).findFirst().orElse(null);
}
return clientAttributeList.get(0);
default boolean mapHasPostfachNachricht(List<GrpcClientAttribute> clientAttributes) {
return findByName(HAS_POSTFACH_NACHRICHT_ATTRIBUTE_NAME, clientAttributes)
.map(GrpcClientAttributeValue::getBoolValue)
.findFirst().orElse(false);
}
default Stream<GrpcClientAttributeValue> findByName(String attributeName, List<GrpcClientAttribute> clientAttributes) {
return clientAttributes.stream()
.filter(attribute -> StringUtils.equals(attribute.getAttributeName(), attributeName))
.map(GrpcClientAttribute::getValue);
}
}
......@@ -28,10 +28,12 @@ public class WiedervorlageRemoteService {
static final String CLIENT_ATTRIBUTE_NEXT_WIEDERVORLAGE_FRIST = "nextWiedervorlageFrist";
static final String ITEM_NAME = "Wiedervorlage";
@GrpcClient(GoofyServerApplication.GRPC_CLIENT)
private ClientAttributeServiceBlockingStub clientAttributeServiceStub;
@GrpcClient(GoofyServerApplication.GRPC_CLIENT)
private VorgangAttachedItemServiceBlockingStub vorgangAttachedItemServiceStub;
@GrpcClient(GoofyServerApplication.GRPC_CLIENT)
private ClientAttributeServiceBlockingStub clientAttributeServiceStub;
@Autowired
private WiedervorlageMapper mapper;
@Autowired
......
......@@ -30,15 +30,11 @@ class WiedervorlageService {
}
Optional<LocalDate> calculateNextFrist(Stream<Wiedervorlage> wiedervorlagen) {
var sortedWiedervorlagen = wiedervorlagen
return wiedervorlagen
.filter(IS_NOT_DONE)
.sorted(Comparator.comparing(Wiedervorlage::getFrist))
.toList();
if (sortedWiedervorlagen.isEmpty()) {
return Optional.empty();
}
return Optional.of(sortedWiedervorlagen.get(0).getFrist());
.map(Wiedervorlage::getFrist)
.findFirst();
}
public Stream<Wiedervorlage> findByVorgangId(String vorgangId) {
......
......@@ -10,7 +10,7 @@ spring:
pathmatch:
matching-strategy: ant-path-matcher
application:
name: Goofy
name: goofy
jackson:
deserialization:
'ADJUST_DATES_TO_CONTEXT_TIME_ZONE': false
......
......@@ -78,7 +78,7 @@ class BinaryFileITCase {
.andExpect(jsonPath("issues[0].messageCode").value("validation_field_file_size_exceeded"))
.andExpect(jsonPath("issues[0].message").value("validation_field_file_size_exceeded"))
.andExpect(jsonPath("issues[0].parameters[0].name").value("unit"))
.andExpect(jsonPath("issues[0].parameters[0].value").value(BinaryFileUnit.MB));
.andExpect(jsonPath("issues[0].parameters[0].value").value(UploadBinaryFileSizeValidator.DEFAULT_UNIT_STRING));
}
@Test
......
package de.itvsh.goofy.common.callcontext;
import static de.itvsh.goofy.common.callcontext.ContextService.KEY_USER_ID;
import static de.itvsh.goofy.common.callcontext.ContextService.KEY_USER_NAME;
import static de.itvsh.goofy.common.callcontext.ContextService.*;
import java.util.Map;
......@@ -9,6 +8,8 @@ import de.itvsh.goofy.common.user.UserTestFactory;
public class CallContextTestFactory {
public static final String CLIENT_NAME = "TEST_CLIENT";
static Map<String, String> createContextMap() {
return Map.of(
KEY_USER_ID, UserTestFactory.ID.toString(),
......
package de.itvsh.goofy.vorgang;
import de.itvsh.goofy.common.callcontext.CallContextTestFactory;
import de.itvsh.ozg.pluto.grpc.clientAttribute.GrpcAccessPermission;
import de.itvsh.ozg.pluto.grpc.clientAttribute.GrpcClientAttribute;
import de.itvsh.ozg.pluto.grpc.clientAttribute.GrpcClientAttribute.Builder;
import de.itvsh.ozg.pluto.grpc.clientAttribute.GrpcClientAttributeValue;
class GrpcClientAttributeTestFactory {
static final String CLIENT = CallContextTestFactory.CLIENT_NAME;
static final GrpcAccessPermission ACCESS = GrpcAccessPermission.READ_WRITE;
static final GrpcClientAttribute create() {
return createBuilder().build();
}
static final Builder createBuilder() {
return GrpcClientAttribute.newBuilder()
.setClientName(CLIENT)
.setAccess(ACCESS);
}
static final GrpcClientAttribute createWith(String attributeName, boolean value) {
return createBuilder().setAttributeName(attributeName)
.setValue(GrpcClientAttributeValue.newBuilder().setBoolValue(value).build())
.build();
}
}
......@@ -75,7 +75,6 @@ class VorgangHeaderMapperTest {
var header = mapper.toVorgangHeader(vorgangHeaderWithEmptyClientAttributes);
assertThat(header.getNextFrist()).isNull();
;
}
@Test
......@@ -94,6 +93,28 @@ class VorgangHeaderMapperTest {
}
}
@Nested
class HasPostfachNachricht {
@Test
void shouldSetFalseIfNotExists() {
var vorgangHeader = GrpcVorgangHeaderTestFactory.createBuilder().clearClientAttributes().build();
var mapped = mapper.toVorgangHeader(vorgangHeader);
assertThat(mapped.isHasPostfachNachricht()).isFalse();
}
@Test
void shouldBeTrue() {
var clientAttribute = GrpcClientAttributeTestFactory.createWith("hasPostfachNachricht", true);
var vorgangHeader = GrpcVorgangHeaderTestFactory.createBuilder().addClientAttributes(clientAttribute).build();
var mapped = mapper.toVorgangHeader(vorgangHeader);
assertThat(mapped.isHasPostfachNachricht()).isTrue();
}
}
private VorgangHeader callMapper() {
return mapper.toVorgangHeader(GrpcVorgangHeaderTestFactory.create());
}
......
......@@ -113,7 +113,7 @@ class WiedervorlageServiceTest {
var nextFrist = calculateNextFrist(Stream.of(fristPast2Days, fristPast1Day, fristFuture1Day, fristFuture2Days));
assertThat(nextFrist.get()).isEqualTo(LocalDate.now().minus(2, ChronoUnit.DAYS));
assertThat(nextFrist).contains(LocalDate.now().minus(2, ChronoUnit.DAYS));
}
@Test
......@@ -125,7 +125,7 @@ class WiedervorlageServiceTest {
var nextFrist = calculateNextFrist(Stream.of(fristPast1DayNotDone, fristPast1DayDone));
assertThat(nextFrist.get()).isEqualTo(LocalDate.now().plus(1, ChronoUnit.DAYS));
assertThat(nextFrist).contains(LocalDate.now().plus(1, ChronoUnit.DAYS));
}
private Optional<LocalDate> calculateNextFrist(Stream<Wiedervorlage> wiedervorlagen) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment