FEAT basic Resource mapping
parent
77b006ab3c
commit
be11516279
|
@ -0,0 +1,30 @@
|
|||
package de.nclazz.resources;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.Singular;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Builder
|
||||
@Data
|
||||
public class ResourceMapping {
|
||||
|
||||
public enum Option {
|
||||
REQUIRED
|
||||
}
|
||||
|
||||
private String label;
|
||||
private String description;
|
||||
|
||||
private Resource defaultResource;
|
||||
private Resource definedResource;
|
||||
|
||||
@Singular
|
||||
private Set<Option> options;
|
||||
|
||||
public boolean exists() {
|
||||
return this.definedResource != null || this.defaultResource != null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package de.nclazz.resources;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class ResourceMappingTest {
|
||||
|
||||
@Test
|
||||
void checkResourceExists() {
|
||||
ResourceMapping mapping = ResourceMapping.builder()
|
||||
.defaultResource(Resource.fromClasspath("/airplane.png"))
|
||||
.definedResource(Resource.fromClasspath("/airplane.png"))
|
||||
.build();
|
||||
|
||||
assertTrue(mapping.exists());
|
||||
|
||||
mapping = ResourceMapping.builder()
|
||||
.build();
|
||||
|
||||
assertFalse(mapping.exists());
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue