use of eu.ggnet.dwoss.customer.ee.entity.projection.AddressLabel in project dwoss by gg-net.
the class CustomerTest method testIsVaildBusinessCustomer.
@Test
public void testIsVaildBusinessCustomer() {
Customer makeValidBusinessCustomer = makeValidBusinessCustomer();
assertThat(makeValidBusinessCustomer.isBusiness()).as("Customer is a Bussines Customer").isTrue();
assertThat(makeValidBusinessCustomer.isValid()).as("Bussnis Customer is vaild").isTrue();
makeValidBusinessCustomer.getCompanies().clear();
Company makeValidCompany = makeValidCompany();
makeValidCompany.setName("");
makeValidBusinessCustomer.getCompanies().add(makeValidCompany);
assertThat(makeValidBusinessCustomer.isValid()).as("Bussnis Customer is not vaild, because the Name of the Compnay is blank").isFalse();
makeValidBusinessCustomer = makeValidBusinessCustomer();
makeValidBusinessCustomer.getAddressLabels().clear();
assertThat(makeValidBusinessCustomer.isValid()).as("Bussnis Customer is not vaild, because there is no AddressLable").isFalse();
makeValidBusinessCustomer = makeValidBusinessCustomer();
AddressLabel shoppingAddressLabel = makeValidAddressLabel();
shoppingAddressLabel.setType(AddressType.SHIPPING);
assertThat(shoppingAddressLabel.getViolationMessage()).as("Valid AddressLabel").isNull();
makeValidBusinessCustomer.getAddressLabels().clear();
makeValidBusinessCustomer.getAddressLabels().add(shoppingAddressLabel);
assertThat(makeValidBusinessCustomer.isValid()).as("Bussnis Customer is not vaild, because there is no AddressLable with Type Invoice").isFalse();
makeValidBusinessCustomer = makeValidBusinessCustomer();
makeValidBusinessCustomer.getAddressLabels().clear();
makeValidBusinessCustomer.getAddressLabels().add(makeValidAddressLabel());
makeValidBusinessCustomer.getAddressLabels().add(makeValidAddressLabel());
makeValidBusinessCustomer.getAddressLabels().add(makeValidAddressLabel());
assertThat(makeValidBusinessCustomer.isValid()).as("Bussnis Customer is not vaild, because there are more than two AddressLables").isFalse();
makeValidBusinessCustomer = makeValidBusinessCustomer();
makeValidBusinessCustomer.getCompanies().clear();
makeValidCompany = makeValidCompany();
makeValidCompany.getAddresses().clear();
assertThat(makeValidCompany.getViolationMessage()).as("company not valid").isNotNull();
makeValidBusinessCustomer.getCompanies().add(makeValidCompany);
assertThat(makeValidBusinessCustomer.isValid()).as("Bussnis Customer is not vaild, the Compnay has no an Address").isFalse();
makeValidBusinessCustomer = makeValidBusinessCustomer();
makeValidBusinessCustomer.getCompanies().clear();
makeValidCompany = makeValidCompany();
makeValidCompany.getCommunications().clear();
makeValidBusinessCustomer.getCompanies().add(makeValidCompany);
assertThat(makeValidCompany.getViolationMessage()).as("valid company without communication").isNull();
assertThat(makeValidBusinessCustomer).as("Bussnis Customer is not vaild, the Compnay is valid but has no an Communications").returns(false, c -> c.isValid());
}
use of eu.ggnet.dwoss.customer.ee.entity.projection.AddressLabel in project dwoss by gg-net.
the class CustomerTest method testIsVaildConsumerCustomer.
@Test
public void testIsVaildConsumerCustomer() {
Customer makeValidConsumer = makeValidConsumer();
assertThat(makeValidConsumer.isConsumer()).as("Customer is a Consumer Customer").isTrue();
makeValidConsumer = makeValidConsumer();
makeValidConsumer.getAddressLabels().add(makeValidAddressLabel());
assertThat(makeValidConsumer.isValid()).as("Consumer Customer is vaild").isTrue();
makeValidConsumer = makeValidConsumer();
makeValidConsumer.getAddressLabels().clear();
assertThat(makeValidConsumer.isValid()).as("Customer is not vaild, because there is no AddressLable").isFalse();
makeValidConsumer = makeValidConsumer();
AddressLabel shoppingAddressLabel = makeValidAddressLabel();
shoppingAddressLabel.setType(AddressType.SHIPPING);
assertThat(shoppingAddressLabel.getViolationMessage()).as("Valid AddressLabel").isNull();
makeValidConsumer.getAddressLabels().clear();
makeValidConsumer.getAddressLabels().add(shoppingAddressLabel);
assertThat(makeValidConsumer.isValid()).as("Customer is not vaild, because there is no AddressLable with Type Invoice").isFalse();
makeValidConsumer = makeValidConsumer();
makeValidConsumer.getAddressLabels().clear();
makeValidConsumer.getAddressLabels().add(makeValidAddressLabel());
makeValidConsumer.getAddressLabels().add(makeValidAddressLabel());
makeValidConsumer.getAddressLabels().add(makeValidAddressLabel());
assertThat(makeValidConsumer.isValid()).as("Customer is not vaild, because there are more than two AddressLables").isFalse();
makeValidConsumer = makeValidConsumer();
makeValidConsumer.getCompanies().clear();
makeValidConsumer.getContacts().clear();
assertThat(makeValidConsumer.isValid()).as("Customer is not vaild, because there is no Company and no Contact is set").isFalse();
makeValidConsumer = makeValidConsumer();
Contact makeValidContact = makeValidContact();
makeValidContact.setLastName("");
assertThat(makeValidContact.getViolationMessage()).as("not valid Contact").isNotNull();
makeValidConsumer.getContacts().add(makeValidContact);
assertThat(makeValidConsumer.isValid()).as("Consumer Customer is not vaild, because the Contact do not have a LastName").isFalse();
}
use of eu.ggnet.dwoss.customer.ee.entity.projection.AddressLabel in project dwoss by gg-net.
the class CustomerViolationMessageTest method testgetViolationMessageConsumerCustomer.
@Test
public void testgetViolationMessageConsumerCustomer() {
Customer consumerCustomer = makeValidConsumerCustomer();
consumerCustomer.getContacts().clear();
assertThat(consumerCustomer.getViolationMessage()).as("ConsumerCustomer without Contacts is invalid").isNotNull();
consumerCustomer = makeValidConsumerCustomer();
consumerCustomer.getCompanies().add(makeValidCompany());
assertThat(consumerCustomer.getViolationMessage()).as("ConsumerCustomer with a Company is invalid").isNotNull();
consumerCustomer = makeValidConsumerCustomer();
consumerCustomer.getAddressLabels().clear();
assertThat(consumerCustomer.getViolationMessage()).as("ConsumerCustomer without AddressLabels is invalid").isNotNull();
consumerCustomer = makeValidConsumerCustomer();
consumerCustomer.getAddressLabels().add(new AddressLabel(null, consumerCustomer.getContacts().get(0), consumerCustomer.getContacts().get(0).getAddresses().get(0), AddressType.SHIPPING));
assertThat(consumerCustomer.getViolationMessage()).as("ConsumerCustomer with more than two AddressLabels is invalid").isNotNull();
consumerCustomer = makeValidConsumerCustomer();
consumerCustomer.getAddressLabels().clear();
consumerCustomer.getAddressLabels().add(new AddressLabel(null, consumerCustomer.getContacts().get(0), consumerCustomer.getContacts().get(0).getAddresses().get(0), AddressType.SHIPPING));
consumerCustomer.getAddressLabels().add(new AddressLabel(makeValidCompany(), consumerCustomer.getContacts().get(0), consumerCustomer.getContacts().get(0).getAddresses().get(0), AddressType.SHIPPING));
assertThat(consumerCustomer.getViolationMessage()).as("ConsumerCustomer without an AddressLabel of Type INVOICE is invalid").isNotNull();
consumerCustomer = makeValidConsumerCustomer();
consumerCustomer.getContacts().forEach(e -> e.getCommunications().clear());
assertThat(consumerCustomer.getViolationMessage()).as("ConsumerCustomer without Communications is invalid").isNotNull();
consumerCustomer = makeValidConsumerCustomer();
Communication invalidEmailCommunication = new Communication(Type.EMAIL, false);
consumerCustomer.getContacts().get(0).getCommunications().add(invalidEmailCommunication);
assertThat(consumerCustomer.getViolationMessage()).as("ConsumerCustomer with invalid Communication is invalid").isNotNull();
consumerCustomer = makeValidConsumerCustomer();
Contact invalidContact = new Contact(Sex.MALE, false, "", "Hans", "");
assertThat(invalidContact.getViolationMessage()).as("Invalid Contact is invalid").isNotNull();
consumerCustomer.getContacts().add(invalidContact);
assertThat(consumerCustomer.getViolationMessage()).as("ConsumerCustomer with invalid Contact is invalid").isNotNull();
consumerCustomer = makeValidConsumerCustomer();
Address invalidAddress = new Address();
invalidAddress.setIsoCountry(Locale.GERMANY);
invalidAddress.setCity("city");
invalidAddress.setStreet("street");
invalidAddress.setZipCode("");
assertThat(invalidAddress.getViolationMessage()).as("Invalid Address is invalid").isNotNull();
consumerCustomer.getContacts().get(0).getAddresses().add(invalidAddress);
assertThat(consumerCustomer.getViolationMessage()).as("ConsumerCustomer with invalid Address is invalid").isNotNull();
consumerCustomer = makeValidConsumerCustomer();
MandatorMetadata invalidMandatorMetadata = new MandatorMetadata();
invalidMandatorMetadata.setPaymentCondition(PaymentCondition.CUSTOMER);
invalidMandatorMetadata.setPaymentMethod(PaymentMethod.DIRECT_DEBIT);
invalidMandatorMetadata.setShippingCondition(ShippingCondition.DEALER_ONE);
assertThat(invalidMandatorMetadata.getViolationMessage()).as("Invalid MandatorMetadata is invalid").isNotNull();
consumerCustomer.getMandatorMetadata().add(invalidMandatorMetadata);
assertThat(consumerCustomer.getViolationMessage()).as("BusinessCustomer with invalid MandatorMetadata is invalid").isNotNull();
}
use of eu.ggnet.dwoss.customer.ee.entity.projection.AddressLabel in project dwoss by gg-net.
the class CustomerTestUtil method testGetViolationMessageSimpleConsumer.
@Test
public void testGetViolationMessageSimpleConsumer() {
Customer simpleConsumer = makeValidSimpleConsumer();
simpleConsumer.getCompanies().add(makeValidCompany());
assertThat(simpleConsumer.getViolationMessage()).as("SimpleConsumer with company is not valid").isNotNull();
simpleConsumer.getCompanies().clear();
assertThat(simpleConsumer.getViolationMessage()).as("SimpleConsumer with contact and without company is valid").isNull();
simpleConsumer.getContacts().clear();
assertThat(simpleConsumer.getViolationMessage()).as("SimpleConsumer without contact is invalid").isNotNull();
simpleConsumer = makeValidSimpleConsumer();
simpleConsumer.getAddressLabels().remove(simpleConsumer.getAddressLabels().stream().filter(label -> label.getType() == AddressType.INVOICE).findAny().get());
assertThat(simpleConsumer.getViolationMessage()).as("Removal of any AddressLabel of type INVOICE from SimpleConsumer is invalid").isNotNull();
simpleConsumer = makeValidSimpleConsumer();
simpleConsumer.getAddressLabels().add(new AddressLabel(null, simpleConsumer.getContacts().get(0), simpleConsumer.getContacts().get(0).getAddresses().get(0), INVOICE));
assertThat(simpleConsumer.getViolationMessage()).as("SimpleConsumer with two addressLabels of type INVOICE is invalid").isNull();
simpleConsumer = makeValidSimpleConsumer();
simpleConsumer.getAddressLabels().add(new AddressLabel(null, simpleConsumer.getContacts().get(0), simpleConsumer.getContacts().get(0).getAddresses().get(0), SHIPPING));
assertThat(simpleConsumer.getViolationMessage()).as("SimpleConsumer with two AddressLabels of unequal types is valid").isNull();
simpleConsumer.getAddressLabels().add(new AddressLabel(null, simpleConsumer.getContacts().get(0), simpleConsumer.getContacts().get(0).getAddresses().get(0), SHIPPING));
assertThat(simpleConsumer.getViolationMessage()).as("SimpleConsumer with three AddressLabels is invalid").isNotNull();
simpleConsumer = makeValidSimpleConsumer();
simpleConsumer.getContacts().clear();
Contact invalidContact = new Contact(Sex.MALE, true, null, "invalid", "");
assertThat(invalidContact.getViolationMessage()).as("Contact without lastName is invalid").isNotNull();
simpleConsumer.getContacts().add(invalidContact);
assertThat(simpleConsumer.getViolationMessage()).as("SimpleConsumer with invalid contact is invalid").isNotNull();
simpleConsumer = makeValidSimpleConsumer();
simpleConsumer.getContacts().get(0).getAddresses().clear();
assertThat(simpleConsumer.getViolationMessage()).as("SimpleConsumer without Address is invalid").isNotNull();
simpleConsumer = makeValidSimpleConsumer();
simpleConsumer.getContacts().get(0).getCommunications().clear();
assertThat(simpleConsumer.getViolationMessage()).as("SimpleConsumer without communications is invalid").isNotNull();
simpleConsumer = makeValidSimpleConsumer();
Communication invalidEmailCommunication = new Communication(Type.EMAIL, false);
simpleConsumer.getContacts().get(0).getCommunications().clear();
simpleConsumer.getContacts().get(0).getCommunications().add(invalidEmailCommunication);
assertThat(simpleConsumer.getViolationMessage()).as("SimpleConsumer with invalid Communication is invalid").isNotNull();
simpleConsumer = makeValidSimpleConsumer();
Address invalidAddress = new Address();
invalidAddress.setIsoCountry(Locale.GERMANY);
invalidAddress.setCity("city");
invalidAddress.setStreet("street");
invalidAddress.setZipCode("");
assertThat(invalidAddress.getViolationMessage()).as("Invalid Address is invalid").isNotNull();
simpleConsumer.getContacts().get(0).getAddresses().clear();
simpleConsumer.getContacts().get(0).getAddresses().add(invalidAddress);
assertThat(simpleConsumer.getViolationMessage()).as("SimpleConsumer with invalid Address is invalid").isNotNull();
}
use of eu.ggnet.dwoss.customer.ee.entity.projection.AddressLabel in project dwoss by gg-net.
the class CustomerTestUtil method makeValidBusinessCustomer.
/**
* @return Valid BusinessCustomer with two AddressLabels, one Communication on it's Company and it's Company's Contact and a CustomerFlag
*/
public static Customer makeValidBusinessCustomer() {
Customer customer = new Customer();
customer.getCompanies().add(makeValidCompany());
customer.getCompanies().get(0).getContacts().add(makeValidContact());
customer.getCompanies().get(0).getCommunications().add(makeValidCommunication(Communication.Type.EMAIL, "testMail@test.net"));
customer.getCompanies().get(0).getContacts().get(0).getCommunications().add(makeValidCommunication(Communication.Type.EMAIL, "testMail@test.net"));
customer.getCompanies().get(0).getContacts().get(0).getAddresses().add(makeValidAddress());
customer.getCompanies().get(0).getAddresses().add(makeValidAddress());
customer.getAddressLabels().add(makeValidInvoiceAddressLabel());
customer.getAddressLabels().add(new AddressLabel(customer.getCompanies().get(0), customer.getCompanies().get(0).getContacts().get(0), customer.getCompanies().get(0).getContacts().get(0).getAddresses().get(0), AddressType.SHIPPING));
customer.getFlags().add(CustomerFlag.CS_UPDATE_CANDIDATE);
assertThat(customer.getViolationMessage()).as("BusinessCustomer does not violate any rule").isNull();
assertThat(customer.isValid()).as("BusinessCustomer is a simple valid business customer").isTrue();
assertThat(customer.isBusiness()).as("BusinessCustomer is a business customer").isTrue();
assertThat(customer.isConsumer()).as("BusinessCustomer is no ConsumerCustomer").isFalse();
assertThat(customer.isSimple()).as("BusinessCustomer is not SimpleBusinessCustomer").isFalse();
assertThat(customer.getSimpleViolationMessage()).as("BusinessCustomer is not simple").isNotNull();
return customer;
}
Aggregations