Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ This project adheres to `Semantic Versioning <https://semver.org/>`_.

* Add ``life.qbic.datamodel.validation.*`` for project code validation. (`#254 <https://github.com/qbicsoftware/data-model-lib/pull/254>`_)

* ``life.qbic.datamodel.dtos.business.facilities.Facility`` can provide a shorthand label now (`#255 <https://github.com/qbicsoftware/data-model-lib/pull/255>`_)

**Fixed**

**Dependencies**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,26 @@ package life.qbic.datamodel.dtos.business.facilities
*/
enum Facility {

CFMB("Core Facility for Medical Bioanalytics"),
IMGAG("Institute for Medical Genetics and Applied Genomics"),
MGM("Institute for Medical Microbiology and Hygiene"),
QBIC("Quantitative Biology Center"),
PCT("Proteome Center Tübingen")
CFMB("Core Facility for Medical Bioanalytics", "CFMB"),
IMGAG("Institute for Medical Genetics and Applied Genomics", "IMGAG"),
MGM("Institute for Medical Microbiology and Hygiene", "MGM"),
QBIC("Quantitative Biology Center", "QBIC"),
CFMB_PCT("Proteomics Facility Tübingen", "Proteomics Facility")

private final String fullName
private final String label

/**
* Creates an instance of a facility enum
* @param fullName The full name representation of the enum
* Creates an instance of a facility enum with shorthand label
* @param fullName The full name representation of the facility
* @param label The shorthand label of the facility
*/
Facility(String fullName) {
Facility(String fullName, String label) {
this.fullName = fullName
this.label = label
}


/**
* Returns to the full name representation of the facility
* @return
Expand All @@ -41,6 +45,14 @@ enum Facility {
return this.fullName
}

/**
* Returns the short representation form of the facility
* @return
*/
String getLabel() {
return this.label
}

/**
* Returns a String representation of the facility enum.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package life.qbic.datamodel.dtos.business.facilities

import spock.lang.Specification

/**
* Tests for the {@link Facility} enum class
*
* @since 2.12.0
*/
class FacilitySpec extends Specification {

def "given an enum, calling the label function returns the right label"() {

when:
String result = facility.label

then:
result == expectedLabel

where:
facility | expectedLabel
Facility.CFMB | "CFMB"
Facility.CFMB_PCT | "Proteomics Facility"
Facility.IMGAG | "IMGAG"
Facility.MGM | "MGM"
Facility.QBIC | "QBIC"
}

}