Search in sources :

Example 1 with AdminEmail

use of teammates.storage.entity.AdminEmail in project teammates by TEAMMATES.

the class AdminEmailAttributesTest method testToEntity.

@Test
public void testToEntity() {
    AdminEmail adminEmail = validAdminEmailAttributesObject.toEntity();
    assertEquals(validAdminEmailAttributesObject.subject, adminEmail.getSubject());
    assertEquals(validAdminEmailAttributesObject.addressReceiver, adminEmail.getAddressReceiver());
    assertEquals(validAdminEmailAttributesObject.groupReceiver, adminEmail.getGroupReceiver());
    assertEquals(validAdminEmailAttributesObject.content, adminEmail.getContent());
    assertEquals(validAdminEmailAttributesObject.sendDate, adminEmail.getSendDate());
}
Also used : AdminEmail(teammates.storage.entity.AdminEmail) Test(org.testng.annotations.Test)

Example 2 with AdminEmail

use of teammates.storage.entity.AdminEmail in project teammates by TEAMMATES.

the class AdminEmailsDb method updateAdminEmailById.

public void updateAdminEmailById(AdminEmailAttributes newAdminEmail, String emailId) throws InvalidParametersException, EntityDoesNotExistException {
    if (!newAdminEmail.isValid()) {
        throw new InvalidParametersException(newAdminEmail.getInvalidityInfo());
    }
    AdminEmail adminEmailToUpdate = getAdminEmailEntity(emailId);
    if (adminEmailToUpdate == null) {
        throw new EntityDoesNotExistException(ERROR_UPDATE_NON_EXISTENT_ACCOUNT + "with Id : " + emailId + ThreadHelper.getCurrentThreadStack());
    }
    newAdminEmail.sanitizeForSaving();
    adminEmailToUpdate.setContent(newAdminEmail.content);
    adminEmailToUpdate.setAddressReceiver(newAdminEmail.addressReceiver);
    adminEmailToUpdate.setGroupReceiver(newAdminEmail.groupReceiver);
    adminEmailToUpdate.setSubject(newAdminEmail.subject);
    adminEmailToUpdate.setIsInTrashBin(newAdminEmail.isInTrashBin);
    adminEmailToUpdate.setSendDate(newAdminEmail.sendDate);
    saveEntity(adminEmailToUpdate, newAdminEmail);
}
Also used : InvalidParametersException(teammates.common.exception.InvalidParametersException) AdminEmail(teammates.storage.entity.AdminEmail) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 3 with AdminEmail

use of teammates.storage.entity.AdminEmail in project teammates by TEAMMATES.

the class AdminEmailAttributesTest method testValueOf.

@Test
public void testValueOf() {
    AdminEmail adminEmail = new AdminEmail(groupReceiverListFileKey, addressReceiverListString, subject, content, date);
    AdminEmailAttributes adminEmailAttributes = AdminEmailAttributes.valueOf(adminEmail);
    assertEquals(adminEmail.getGroupReceiver(), adminEmailAttributes.groupReceiver);
    assertEquals(adminEmail.getAddressReceiver(), adminEmailAttributes.addressReceiver);
    assertEquals(adminEmail.getSubject(), adminEmailAttributes.subject);
    assertEquals(adminEmail.getContent(), adminEmailAttributes.content);
    assertEquals(adminEmail.getSendDate(), adminEmailAttributes.sendDate);
    assertTrue("Valid input", adminEmailAttributes.isValid());
}
Also used : AdminEmail(teammates.storage.entity.AdminEmail) AdminEmailAttributes(teammates.common.datatransfer.attributes.AdminEmailAttributes) Test(org.testng.annotations.Test)

Example 4 with AdminEmail

use of teammates.storage.entity.AdminEmail in project teammates by TEAMMATES.

the class AdminEmailsDb method updateAdminEmail.

public void updateAdminEmail(AdminEmailAttributes ae) throws InvalidParametersException, EntityDoesNotExistException {
    if (!ae.isValid()) {
        throw new InvalidParametersException(ae.getInvalidityInfo());
    }
    AdminEmail adminEmailToUpdate = getAdminEmailEntity(ae.emailId);
    if (adminEmailToUpdate == null) {
        throw new EntityDoesNotExistException(ERROR_UPDATE_NON_EXISTENT_ACCOUNT + ae.getSubject() + "/" + ae.getSendDate() + ThreadHelper.getCurrentThreadStack());
    }
    ae.sanitizeForSaving();
    adminEmailToUpdate.setContent(ae.content);
    adminEmailToUpdate.setAddressReceiver(ae.addressReceiver);
    adminEmailToUpdate.setGroupReceiver(ae.groupReceiver);
    adminEmailToUpdate.setSubject(ae.subject);
    adminEmailToUpdate.setIsInTrashBin(ae.isInTrashBin);
    adminEmailToUpdate.setSendDate(ae.sendDate);
    saveEntity(adminEmailToUpdate, ae);
}
Also used : InvalidParametersException(teammates.common.exception.InvalidParametersException) AdminEmail(teammates.storage.entity.AdminEmail) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Aggregations

AdminEmail (teammates.storage.entity.AdminEmail)4 Test (org.testng.annotations.Test)2 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)2 InvalidParametersException (teammates.common.exception.InvalidParametersException)2 AdminEmailAttributes (teammates.common.datatransfer.attributes.AdminEmailAttributes)1