Skip to content
Snippets Groups Projects
Unverified Commit 2611e3e2 authored by Martin Weise's avatar Martin Weise
Browse files

Fixed the tests

parent 10803777
No related branches found
No related tags found
4 merge requests!231CI: Remove build for log-service,!228Better error message handling in the frontend,!223Release of version 1.4.0,!215Resolve "Fix the unit independent search"
Showing
with 151 additions and 47 deletions
...@@ -9,12 +9,18 @@ public class AccessTypeConverter implements AttributeConverter<AccessType, Strin ...@@ -9,12 +9,18 @@ public class AccessTypeConverter implements AttributeConverter<AccessType, Strin
@Override @Override
public String convertToDatabaseColumn(AccessType accessType) { public String convertToDatabaseColumn(AccessType accessType) {
if (accessType == null) {
return null;
}
return accessType.name() return accessType.name()
.toLowerCase(); .toLowerCase();
} }
@Override @Override
public AccessType convertToEntityAttribute(String accessType) { public AccessType convertToEntityAttribute(String accessType) {
if (accessType == null) {
return null;
}
return AccessType.valueOf(accessType.toUpperCase()); return AccessType.valueOf(accessType.toUpperCase());
} }
} }
package at.tuwien.converters;
import at.tuwien.entities.maintenance.BannerMessageType;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
@Converter
public class BannerMessageTypeConverter implements AttributeConverter<BannerMessageType, String> {
@Override
public String convertToDatabaseColumn(BannerMessageType bannerMessageType) {
if (bannerMessageType == null) {
return null;
}
return bannerMessageType.name()
.toLowerCase();
}
@Override
public BannerMessageType convertToEntityAttribute(String bannerMessageType) {
if (bannerMessageType == null) {
return null;
}
return BannerMessageType.valueOf(bannerMessageType.toUpperCase());
}
}
...@@ -8,13 +8,19 @@ import jakarta.persistence.Converter; ...@@ -8,13 +8,19 @@ import jakarta.persistence.Converter;
public class IdentifierAffiliationIdentifierSchemeTypeConverter implements AttributeConverter<AffiliationIdentifierSchemeType, String> { public class IdentifierAffiliationIdentifierSchemeTypeConverter implements AttributeConverter<AffiliationIdentifierSchemeType, String> {
@Override @Override
public String convertToDatabaseColumn(AffiliationIdentifierSchemeType columnType) { public String convertToDatabaseColumn(AffiliationIdentifierSchemeType affiliationIdentifierSchemeType) {
return columnType.name() if (affiliationIdentifierSchemeType == null) {
return null;
}
return affiliationIdentifierSchemeType.name()
.toLowerCase(); .toLowerCase();
} }
@Override @Override
public AffiliationIdentifierSchemeType convertToEntityAttribute(String columnType) { public AffiliationIdentifierSchemeType convertToEntityAttribute(String affiliationIdentifierSchemeType) {
return AffiliationIdentifierSchemeType.valueOf(columnType.toUpperCase()); if (affiliationIdentifierSchemeType == null) {
return null;
}
return AffiliationIdentifierSchemeType.valueOf(affiliationIdentifierSchemeType.toUpperCase());
} }
} }
...@@ -8,13 +8,19 @@ import jakarta.persistence.Converter; ...@@ -8,13 +8,19 @@ import jakarta.persistence.Converter;
public class IdentifierDescriptionTypeConverter implements AttributeConverter<DescriptionType, String> { public class IdentifierDescriptionTypeConverter implements AttributeConverter<DescriptionType, String> {
@Override @Override
public String convertToDatabaseColumn(DescriptionType columnType) { public String convertToDatabaseColumn(DescriptionType descriptionType) {
return columnType.name() if (descriptionType == null) {
return null;
}
return descriptionType.name()
.toLowerCase(); .toLowerCase();
} }
@Override @Override
public DescriptionType convertToEntityAttribute(String columnType) { public DescriptionType convertToEntityAttribute(String descriptionType) {
return DescriptionType.valueOf(columnType.toUpperCase()); if (descriptionType == null) {
return null;
}
return DescriptionType.valueOf(descriptionType.toUpperCase());
} }
} }
...@@ -8,13 +8,19 @@ import jakarta.persistence.Converter; ...@@ -8,13 +8,19 @@ import jakarta.persistence.Converter;
public class IdentifierFunderTypeConverter implements AttributeConverter<IdentifierFunderType, String> { public class IdentifierFunderTypeConverter implements AttributeConverter<IdentifierFunderType, String> {
@Override @Override
public String convertToDatabaseColumn(IdentifierFunderType columnType) { public String convertToDatabaseColumn(IdentifierFunderType identifierFunderType) {
return columnType.name() if (identifierFunderType == null) {
return null;
}
return identifierFunderType.name()
.toLowerCase(); .toLowerCase();
} }
@Override @Override
public IdentifierFunderType convertToEntityAttribute(String columnType) { public IdentifierFunderType convertToEntityAttribute(String identifierFunderType) {
return IdentifierFunderType.valueOf(columnType.toUpperCase()); if (identifierFunderType == null) {
return null;
}
return IdentifierFunderType.valueOf(identifierFunderType.toUpperCase());
} }
} }
...@@ -8,13 +8,19 @@ import jakarta.persistence.Converter; ...@@ -8,13 +8,19 @@ import jakarta.persistence.Converter;
public class IdentifierIdentifierTypeConverter implements AttributeConverter<IdentifierType, String> { public class IdentifierIdentifierTypeConverter implements AttributeConverter<IdentifierType, String> {
@Override @Override
public String convertToDatabaseColumn(IdentifierType columnType) { public String convertToDatabaseColumn(IdentifierType identifierType) {
return columnType.name() if (identifierType == null) {
return null;
}
return identifierType.name()
.toLowerCase(); .toLowerCase();
} }
@Override @Override
public IdentifierType convertToEntityAttribute(String columnType) { public IdentifierType convertToEntityAttribute(String identifierType) {
return IdentifierType.valueOf(columnType.toUpperCase()); if (identifierType == null) {
return null;
}
return IdentifierType.valueOf(identifierType.toUpperCase());
} }
} }
...@@ -8,13 +8,19 @@ import jakarta.persistence.Converter; ...@@ -8,13 +8,19 @@ import jakarta.persistence.Converter;
public class IdentifierNameIdentifierSchemeTypeConverter implements AttributeConverter<NameIdentifierSchemeType, String> { public class IdentifierNameIdentifierSchemeTypeConverter implements AttributeConverter<NameIdentifierSchemeType, String> {
@Override @Override
public String convertToDatabaseColumn(NameIdentifierSchemeType columnType) { public String convertToDatabaseColumn(NameIdentifierSchemeType nameIdentifierSchemeType) {
return columnType.name() if (nameIdentifierSchemeType == null) {
return null;
}
return nameIdentifierSchemeType.name()
.toLowerCase(); .toLowerCase();
} }
@Override @Override
public NameIdentifierSchemeType convertToEntityAttribute(String columnType) { public NameIdentifierSchemeType convertToEntityAttribute(String nameIdentifierSchemeType) {
return NameIdentifierSchemeType.valueOf(columnType.toUpperCase()); if (nameIdentifierSchemeType == null) {
return null;
}
return NameIdentifierSchemeType.valueOf(nameIdentifierSchemeType.toUpperCase());
} }
} }
...@@ -9,13 +9,19 @@ import jakarta.persistence.Converter; ...@@ -9,13 +9,19 @@ import jakarta.persistence.Converter;
public class IdentifierNameTypeConverter implements AttributeConverter<NameType, String> { public class IdentifierNameTypeConverter implements AttributeConverter<NameType, String> {
@Override @Override
public String convertToDatabaseColumn(NameType columnType) { public String convertToDatabaseColumn(NameType nameType) {
return columnType.name() if (nameType == null) {
return null;
}
return nameType.name()
.toLowerCase(); .toLowerCase();
} }
@Override @Override
public NameType convertToEntityAttribute(String columnType) { public NameType convertToEntityAttribute(String nameType) {
return NameType.valueOf(columnType.toUpperCase()); if (nameType == null) {
return null;
}
return NameType.valueOf(nameType.toUpperCase());
} }
} }
...@@ -8,13 +8,19 @@ import jakarta.persistence.Converter; ...@@ -8,13 +8,19 @@ import jakarta.persistence.Converter;
public class IdentifierRelatedTypeConverter implements AttributeConverter<RelatedType, String> { public class IdentifierRelatedTypeConverter implements AttributeConverter<RelatedType, String> {
@Override @Override
public String convertToDatabaseColumn(RelatedType columnType) { public String convertToDatabaseColumn(RelatedType relatedType) {
return columnType.name() if (relatedType == null) {
return null;
}
return relatedType.name()
.toLowerCase(); .toLowerCase();
} }
@Override @Override
public RelatedType convertToEntityAttribute(String columnType) { public RelatedType convertToEntityAttribute(String relatedType) {
return RelatedType.valueOf(columnType.toUpperCase()); if (relatedType == null) {
return null;
}
return RelatedType.valueOf(relatedType.toUpperCase());
} }
} }
...@@ -8,13 +8,19 @@ import jakarta.persistence.Converter; ...@@ -8,13 +8,19 @@ import jakarta.persistence.Converter;
public class IdentifierVisibilityTypeConverter implements AttributeConverter<VisibilityType, String> { public class IdentifierVisibilityTypeConverter implements AttributeConverter<VisibilityType, String> {
@Override @Override
public String convertToDatabaseColumn(VisibilityType columnType) { public String convertToDatabaseColumn(VisibilityType visibilityType) {
return columnType.name() if (visibilityType == null) {
return null;
}
return visibilityType.name()
.toLowerCase(); .toLowerCase();
} }
@Override @Override
public VisibilityType convertToEntityAttribute(String columnType) { public VisibilityType convertToEntityAttribute(String visibilityType) {
return VisibilityType.valueOf(columnType.toUpperCase()); if (visibilityType == null) {
return null;
}
return VisibilityType.valueOf(visibilityType.toUpperCase());
} }
} }
...@@ -8,13 +8,19 @@ import jakarta.persistence.Converter; ...@@ -8,13 +8,19 @@ import jakarta.persistence.Converter;
public class LanguageTypeConverter implements AttributeConverter<LanguageType, String> { public class LanguageTypeConverter implements AttributeConverter<LanguageType, String> {
@Override @Override
public String convertToDatabaseColumn(LanguageType columnType) { public String convertToDatabaseColumn(LanguageType languageType) {
return columnType.name() if (languageType == null) {
return null;
}
return languageType.name()
.toLowerCase(); .toLowerCase();
} }
@Override @Override
public LanguageType convertToEntityAttribute(String columnType) { public LanguageType convertToEntityAttribute(String languageType) {
return LanguageType.valueOf(columnType.toUpperCase()); if (languageType == null) {
return null;
}
return LanguageType.valueOf(languageType.toUpperCase());
} }
} }
...@@ -8,13 +8,19 @@ import jakarta.persistence.Converter; ...@@ -8,13 +8,19 @@ import jakarta.persistence.Converter;
public class TableColumnTypeConverter implements AttributeConverter<TableColumnType, String> { public class TableColumnTypeConverter implements AttributeConverter<TableColumnType, String> {
@Override @Override
public String convertToDatabaseColumn(TableColumnType columnType) { public String convertToDatabaseColumn(TableColumnType tableColumnType) {
return columnType.name() if (tableColumnType == null) {
return null;
}
return tableColumnType.name()
.toLowerCase(); .toLowerCase();
} }
@Override @Override
public TableColumnType convertToEntityAttribute(String columnType) { public TableColumnType convertToEntityAttribute(String tableColumnType) {
return TableColumnType.valueOf(columnType.toUpperCase()); if (tableColumnType == null) {
return null;
}
return TableColumnType.valueOf(tableColumnType.toUpperCase());
} }
} }
package at.tuwien.entities.maintenance; package at.tuwien.entities.maintenance;
import at.tuwien.converters.BannerMessageTypeConverter;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.*; import lombok.*;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
...@@ -27,8 +28,8 @@ public class BannerMessage { ...@@ -27,8 +28,8 @@ public class BannerMessage {
@Column(updatable = false, nullable = false) @Column(updatable = false, nullable = false)
private Long id; private Long id;
@Enumerated(EnumType.STRING)
@Column(nullable = false, columnDefinition = "enum('error', 'warning', 'info')") @Column(nullable = false, columnDefinition = "enum('error', 'warning', 'info')")
@Convert(converter = BannerMessageTypeConverter.class)
private BannerMessageType type; private BannerMessageType type;
@Column(nullable = false) @Column(nullable = false)
......
package at.tuwien.entities.maintenance; package at.tuwien.entities.maintenance;
import lombok.Getter; import lombok.Getter;
import lombok.ToString;
@Getter @Getter
@ToString
public enum BannerMessageType { public enum BannerMessageType {
WARNING,
ERROR, WARNING("warning"),
INFO;
ERROR("error"),
INFO("info");
private String name;
BannerMessageType(String name) {
this.name = name;
}
@Override
public String toString() {
return this.name;
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment