130 lines
4.0 KiB
Java
130 lines
4.0 KiB
Java
package src.fr.test;
|
|
import java.util.Set;
|
|
import java.util.HashSet;
|
|
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
|
|
import src.fr.impl.*;
|
|
import src.fr.api.*;
|
|
|
|
|
|
public class test {
|
|
|
|
Category Engine = new CategoryImpl("Engine");
|
|
Category Transmission = new CategoryImpl("Transmission");
|
|
Category Exterior= new CategoryImpl("Exterior");
|
|
Category Interior= new CategoryImpl("Interior");
|
|
|
|
//PartType
|
|
PartType EG100= new PartTypeImpl("EG100", Engine);
|
|
PartType EG133= new PartTypeImpl("EG133", Engine);
|
|
PartType EG210= new PartTypeImpl("EG210", Engine);
|
|
PartType ED110= new PartTypeImpl("ED110", Engine);
|
|
PartType ED180= new PartTypeImpl("ED180", Engine);
|
|
PartType EH120= new PartTypeImpl("EH120", Engine);
|
|
|
|
PartType TM5= new PartTypeImpl("TM5", Transmission);
|
|
PartType TM6= new PartTypeImpl("TM6", Transmission);
|
|
PartType TA5= new PartTypeImpl("TA5", Transmission);
|
|
PartType TS6= new PartTypeImpl("TS6", Transmission);
|
|
PartType TSF7= new PartTypeImpl("TSF7", Transmission);
|
|
PartType TC120= new PartTypeImpl("TC120", Transmission);
|
|
|
|
PartType XC= new PartTypeImpl("XC", Exterior);
|
|
PartType XM= new PartTypeImpl("XM", Exterior);
|
|
PartType XS= new PartTypeImpl("XS", Exterior);
|
|
|
|
PartType IN= new PartTypeImpl("IN", Interior);
|
|
PartType IH= new PartTypeImpl("IH", Interior);
|
|
PartType IS= new PartTypeImpl("IS", Interior);
|
|
|
|
CompatibilityManager cm = new CompatibilityManagerImpl();
|
|
|
|
@Before
|
|
public void init(){
|
|
|
|
|
|
Set<PartType> EH120Requirement = new HashSet<PartType>();
|
|
EH120Requirement.add(TC120);
|
|
|
|
Set<PartType> TA5Incompatibilities = new HashSet<PartType>();
|
|
TA5Incompatibilities.add(EG100);
|
|
|
|
Set<PartType> TSF7Incompatibilities = new HashSet<PartType>();
|
|
TSF7Incompatibilities.add(EG100);
|
|
TSF7Incompatibilities.add(EG133);
|
|
TSF7Incompatibilities.add(ED110);
|
|
|
|
Set<PartType> TC120Requirement = new HashSet<PartType>();
|
|
TC120Requirement.add(EH120);
|
|
|
|
Set<PartType> XCIncompatibilities = new HashSet<PartType>();
|
|
XCIncompatibilities.add(EG210);
|
|
|
|
Set<PartType> XMIncompatibilities = new HashSet<PartType>();
|
|
XMIncompatibilities.add(EG100);
|
|
|
|
Set<PartType> XSIncompatibilities = new HashSet<PartType>();
|
|
XSIncompatibilities.add(EG100);
|
|
Set<PartType> XSRequirement = new HashSet<PartType>();
|
|
XSRequirement.add(IS);
|
|
|
|
Set<PartType> ISIncompatibilities = new HashSet<PartType>();
|
|
ISIncompatibilities.add(EG100);
|
|
ISIncompatibilities.add(TM5);
|
|
Set<PartType> ISRequirement = new HashSet<PartType>();
|
|
ISRequirement.add(XS);
|
|
|
|
cm.addRequirements(EH120, EH120Requirement);
|
|
cm.addIncompatibilities(TA5, TA5Incompatibilities);
|
|
cm.addIncompatibilities(TSF7, TSF7Incompatibilities);
|
|
cm.addRequirements(TC120, TC120Requirement);
|
|
cm.addIncompatibilities(XC, XCIncompatibilities);
|
|
cm.addIncompatibilities(XM, XMIncompatibilities);
|
|
cm.addIncompatibilities(XS, XSIncompatibilities);
|
|
cm.addRequirements(XS, XSRequirement);
|
|
cm.addIncompatibilities(IS, ISIncompatibilities);
|
|
cm.addRequirements(IS, ISRequirement);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@Test
|
|
public void test_1_Incompatibilities_1(){
|
|
assertTrue(cm.getIncompatibilities(TA5).contains(EG100));
|
|
}
|
|
|
|
@Test
|
|
public void test_multiple_Incompatibilities_2(){
|
|
assertTrue(
|
|
cm.getIncompatibilities(TSF7).contains(EG100)&&
|
|
cm.getIncompatibilities(TSF7).contains(EG133)&&
|
|
cm.getIncompatibilities(TSF7).contains(ED110)
|
|
);
|
|
}
|
|
|
|
@Test
|
|
public void test_1_Requirements_3(){
|
|
assertTrue(cm.getRequirements(EH120).contains(TC120));
|
|
}
|
|
|
|
@Test
|
|
public void test_Empty_Incompatibilities_4(){
|
|
assertTrue(cm.getIncompatibilities(EH120).isEmpty());
|
|
}
|
|
|
|
@Test
|
|
public void test_Empty_Requirements_5(){
|
|
assertTrue(cm.getRequirements(ED180).isEmpty());
|
|
}
|
|
|
|
|
|
|
|
}
|