Skip to content
Snippets Groups Projects
Commit b5af1f41 authored by srosse's avatar srosse
Browse files

OO-291: test reservations, add unit tests for open group with a date limitation

parent 798ab79c
No related branches found
No related tags found
No related merge requests found
......@@ -108,7 +108,7 @@ public class EnrollmentManager extends BasicManager {
//reservation has the highest priority over max participant
ResourceReservation reservation = acService.getReservation(identity, reloadedGroup.getResource());
logInfo("doEnroll - participantsCounter: " + participantsCounter + ", reservations: " + reservations + " maxParticipants: " + reloadedGroup.getMaxParticipants().intValue(), identity.getName());
if (reservation == null || (participantsCounter + reservations) >= reloadedGroup.getMaxParticipants().intValue()) {
if (reservation == null && (participantsCounter + reservations) >= reloadedGroup.getMaxParticipants().intValue()) {
// already full, show error and updated choose page again
if (!reloadedGroup.getWaitingListEnabled().booleanValue()) {
// No Waiting List => List is full
......
......@@ -933,6 +933,16 @@ create table if not exists o_ac_transaction (
primary key (transaction_id)
);
create table if not exists o_ac_reservation (
reservation_id bigint NOT NULL,
creationdate datetime,
lastmodified datetime,
version mediumint unsigned not null,
fk_identity bigint not null,
fk_resource bigint not null,
primary key (reservation_id)
);
create table if not exists o_ac_paypal_transaction (
transaction_id int8 not null,
version int8 not null,
......@@ -1297,6 +1307,7 @@ alter table o_ac_order ENGINE = InnoDB;
alter table o_ac_order_part ENGINE = InnoDB;
alter table o_ac_order_line ENGINE = InnoDB;
alter table o_ac_transaction ENGINE = InnoDB;
alter table o_ac_offer ENGINE = InnoDB;
alter table o_ac_paypal_transaction ENGINE = InnoDB;
alter table o_as_eff_statement ENGINE = InnoDB;
alter table o_as_user_course_infos ENGINE = InnoDB;
......
......@@ -159,27 +159,41 @@ create table o_ac_paypal_transaction (
order_part_id int8 not null,
method_id int8 not null,
success_uuid varchar(32) not null,
cancel_uuid varchar(32) not null,
amount_amount DECIMAL,
amount_currency_code VARCHAR(3),
cancel_uuid varchar(32) not null,
amount_amount DECIMAL,
amount_currency_code VARCHAR(3),
pay_response_date timestamp,
pay_key varchar(255),
ack varchar(255),
build varchar(255),
coorelation_id varchar(255),
payment_exec_status varchar(255),
ipn_transaction_id varchar(255),
ipn_transaction_status varchar(255),
ipn_sender_transaction_id varchar(255),
ipn_sender_transaction_status varchar(255),
ipn_sender_email varchar(255),
ipn_verify_sign varchar(255),
ipn_pending_reason varchar(255),
trx_status VARCHAR(32) not null default 'NEW',
trx_amount DECIMAL,
trx_currency_code VARCHAR(3),
ack varchar(255),
build varchar(255),
coorelation_id varchar(255),
payment_exec_status varchar(255),
ipn_transaction_id varchar(255),
ipn_transaction_status varchar(255),
ipn_sender_transaction_id varchar(255),
ipn_sender_transaction_status varchar(255),
ipn_sender_email varchar(255),
ipn_verify_sign varchar(255),
ipn_pending_reason varchar(255),
trx_status VARCHAR(32) not null default 'NEW',
trx_amount DECIMAL,
trx_currency_code VARCHAR(3),
primary key (transaction_id)
);
create index paypal_pay_key_idx on o_ac_paypal_transaction (pay_key);
create index paypal_pay_trx_id_idx on o_ac_paypal_transaction (ipn_transaction_id);
create index paypal_pay_s_trx_id_idx on o_ac_paypal_transaction (ipn_sender_transaction_id);
create table if not exists o_ac_reservation (
reservation_id int8 NOT NULL,
creationdate timestamp,
lastmodified timestamp,
version int4 not null,
fk_identity int8 not null,
fk_resource int8 not null,
primary key (reservation_id)
);
......@@ -797,6 +797,16 @@ create table o_ac_transaction (
primary key (transaction_id)
);
create table if not exists o_ac_reservation (
reservation_id bigint NOT NULL,
creationdate datetime,
lastmodified datetime,
version mediumint unsigned not null,
fk_identity bigint not null,
fk_resource bigint not null,
primary key (reservation_id)
);
create table o_ac_paypal_transaction (
transaction_id int8 not null,
version int8 not null,
......
......@@ -22,6 +22,7 @@ package org.olat.group.test;
import static org.junit.Assert.assertNotNull;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;
......@@ -924,6 +925,44 @@ public class BusinessGroupDAOTest extends OlatTestCase {
}
}
@Test
public void findPublicGroupsLimitedDate() {
//create a group with an access control limited by a valid date
BusinessGroup groupVisible = businessGroupDao.createAndPersist(null, "access-grp-2", "access-grp-2-desc", 0, 5, true, false, true, false, false);
//create and save an offer
Offer offer = acService.createOffer(groupVisible.getResource(), "TestBGWorkflow");
Calendar cal = Calendar.getInstance();
cal.add(Calendar.HOUR_OF_DAY, -1);
offer.setValidFrom(cal.getTime());
cal.add(Calendar.HOUR_OF_DAY, 2);
offer.setValidTo(cal.getTime());
assertNotNull(offer);
acService.save(offer);
//create a group with an access control limited by dates in the past
BusinessGroup oldGroup = businessGroupDao.createAndPersist(null, "access-grp-3", "access-grp-3-desc", 0, 5, true, false, true, false, false);
//create and save an offer
Offer oldOffer = acService.createOffer(oldGroup.getResource(), "TestBGWorkflow");
cal.add(Calendar.HOUR_OF_DAY, -5);
oldOffer.setValidFrom(cal.getTime());
cal.add(Calendar.HOUR_OF_DAY, -5);
oldOffer.setValidTo(cal.getTime());
assertNotNull(oldOffer);
acService.save(oldOffer);
dbInstance.commitAndCloseSession();
//retrieve the offer
SearchBusinessGroupParams paramsAll = new SearchBusinessGroupParams();
paramsAll.setPublicGroups(Boolean.TRUE);
List<BusinessGroup> accessGroups = businessGroupDao.findBusinessGroups(paramsAll, null, 0, 0);
Assert.assertNotNull(accessGroups);
Assert.assertTrue(accessGroups.size() >= 1);
Assert.assertTrue(accessGroups.contains(groupVisible));
Assert.assertFalse(accessGroups.contains(oldGroup));
}
@Test
public void findBusinessGroupsWithResources() {
//create a group attach to a resource
......
......@@ -155,6 +155,7 @@ import org.junit.runners.Suite;
org.olat.resource.accesscontrol.ACOfferManagerTest.class,
org.olat.resource.accesscontrol.ACOrderManagerTest.class,
org.olat.resource.accesscontrol.ACTransactionManagerTest.class,
org.olat.resource.accesscontrol.ACReservationDAOTest.class,
org.olat.core.util.vfs.VersionManagerTest.class,
/**
* Pure JUnit test without need of framework
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment