package tests; import static org.junit.Assert.*; import org.junit.Test; import models.dataConstraintModel.*; public class DataConstraintModelTest { @Test public void test() { // Construct a data constraint architecture model. DataConstraintModel model = new DataConstraintModel(); ResourcePath customer_off = new ResourcePath("customers.{customer_id}.off", 1); ResourcePath customer_add = new ResourcePath("customers.{customer_id}.add", 1); ResourcePath company_add = new ResourcePath("companies.{company_id}.add", 1); Channel gin_1 = new Channel("gin_1"); // set customer's office GroupSelector x1 = new GroupSelector(); ChannelMember customer_off_1 = new ChannelMember(customer_off); customer_off_1.addSelector(x1); gin_1.addChannelMember(customer_off_1); assertEquals(customer_off.getNumberOfParameters(), customer_off_1.getSelectors().size()); Channel gin_2 = new Channel("gin_2"); // set companie's address GroupSelector x2 = new GroupSelector(); ChannelMember company_add_1 = new ChannelMember(company_add); company_add_1.addSelector(x2); gin_2.addChannelMember(company_add_1); assertEquals(company_add.getNumberOfParameters(), company_add_1.getSelectors().size()); Channel g = new Channel("g"); // update customer's address GroupSelector x3 = new GroupSelector(); ChannelSelector y = new ChannelSelector(); ChannelMember customer_off_2 = new ChannelMember(customer_off); ChannelMember company_add_2 = new ChannelMember(company_add); ChannelMember customer_add_2 = new ChannelMember(customer_add); customer_off_2.addSelector(x3); company_add_2.addSelector(y); customer_add_2.addSelector(x3); g.addChannelMember(customer_off_2); g.addChannelMember(customer_add_2); g.addChannelMember(company_add_2); assertEquals(customer_off.getNumberOfParameters(), customer_off_2.getSelectors().size()); assertEquals(customer_add.getNumberOfParameters(), customer_add_2.getSelectors().size()); assertEquals(company_add.getNumberOfParameters(), company_add_2.getSelectors().size()); model.addIOChannel(gin_1); model.addIOChannel(gin_2); model.addChannel(g); // Check the model. assertEquals(3, model.getResourcePaths().size()); assertEquals(2, model.getIOChannels().size()); assertEquals(1, model.getChannels().size()); } }