brigning down group tpes
This commit is contained in:
buisnesslogic/src
restservice/src/main/java/com/plannaplan
controllers
responses
@ -1,23 +1,39 @@
|
||||
package com.plannaplan.types;
|
||||
|
||||
/**
|
||||
* GroupType contains types: LECTURE, CLASS, LAB, SEMINAR, CONSERVATORY, PRATICE
|
||||
* GroupType contains types: LECTURE, CLASS, LAB, SEMINAR, CONSERVATORY, PRATICE
|
||||
*/
|
||||
|
||||
public enum GroupType {
|
||||
LECTURE("Wykład"), CLASS("Ćwiczenia"), LAB("Laboratorium"), SEMINAR("Seminarium"),CONSERVATORY("Konwersatorium"), PRATICE("Praktyka");
|
||||
LECTURE("Wykład"), CLASS("Ćwiczenia"), LAB("Laboratorium"), SEMINAR("Seminarium"), CONSERVATORY("Konwersatorium"),
|
||||
PRATICE("Praktyka");
|
||||
|
||||
public final String type;
|
||||
|
||||
private GroupType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type as string
|
||||
* @return Enum converted from provided string
|
||||
*/
|
||||
public final static GroupType getType(String type) {
|
||||
for (GroupType d : values()) {
|
||||
if (d.type.equals(type)) {
|
||||
return d;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type group type to check
|
||||
* @return general convertion to bring down tours to two generals LECTURE and
|
||||
* CLASS. To class are included: CLASS, LAB, SEMINAR, CONSERVATORY,
|
||||
* PRATICE.
|
||||
*/
|
||||
public final static GroupType isLectureOrClass(GroupType type) {
|
||||
return type == GroupType.LECTURE ? GroupType.LECTURE : GroupType.CLASS;
|
||||
}
|
||||
}
|
68
buisnesslogic/src/test/java/com/plannaplan/types/GroupTypeTest.java
Executable file
68
buisnesslogic/src/test/java/com/plannaplan/types/GroupTypeTest.java
Executable file
@ -0,0 +1,68 @@
|
||||
package com.plannaplan.types;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class GroupTypeTest {
|
||||
@Test
|
||||
public void shouldBeLecture() {
|
||||
assertTrue(GroupType.isLectureOrClass(GroupType.LECTURE) == GroupType.LECTURE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldBeClass1() {
|
||||
assertTrue(GroupType.isLectureOrClass(GroupType.CLASS) == GroupType.CLASS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldBeClass2() {
|
||||
assertTrue(GroupType.isLectureOrClass(GroupType.CONSERVATORY) == GroupType.CLASS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldBeClass3() {
|
||||
assertTrue(GroupType.isLectureOrClass(GroupType.LAB) == GroupType.CLASS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldBeClass4() {
|
||||
assertTrue(GroupType.isLectureOrClass(GroupType.PRATICE) == GroupType.CLASS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldBeClass5() {
|
||||
assertTrue(GroupType.isLectureOrClass(GroupType.SEMINAR) == GroupType.CLASS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCastFromString1() {
|
||||
assertTrue(GroupType.getType("Ćwiczenia") == GroupType.CLASS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCastFromString2() {
|
||||
assertTrue(GroupType.getType("Wykład") == GroupType.LECTURE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCastFromString3() {
|
||||
assertTrue(GroupType.getType("Laboratorium") == GroupType.LAB);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCastFromString4() {
|
||||
assertTrue(GroupType.getType("Seminarium") == GroupType.SEMINAR);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCastFromString5() {
|
||||
assertTrue(GroupType.getType("Konwersatorium") == GroupType.CONSERVATORY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCastFromString6() {
|
||||
assertTrue(GroupType.getType("Praktyka") == GroupType.PRATICE);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user