Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
maxi297 committed Apr 11, 2013
1 parent 8f60910 commit 46bc538
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package ca.ulaval.glo4002.acceptanceTests;

import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import ca.ulaval.glo4002.testFixtures.TestFixture;

public class TestAlarmLog {

private static TestFixture fixture;

@BeforeClass
public static void setUpClass() throws Exception {
fixture = new TestFixture();
fixture.initServers();
}

@Before
public void setUp() throws Exception {
fixture.createAlarmSystem();
fixture.armSystem();
}

@AfterClass
public static void tearDownClass() throws Exception {
fixture.stopServers();
}

@Test
public void emptyAlarmLog() {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public class TestFixture {
private static final int THIRTY_TWO_SECONDS_IN_MILLISECONDS = 32000;
private static final int THIRTY_SECONDS_IN_MILLISECONDS = 30000;
private static final String AN_ADDRESS = "123 rue ville";
private static final String EMPTY_LOG_NOTICE = "There is no alarms for this user.";
private static final String LOG_INTRUSION_NOTICE = "INTRUSION";
private static final String LOG_FIRE_NOTICE = "FIRE";
// FIXME
private static final String ALARM_LOG_RESOURCE = "http://localhost/alarm/";

private CentralServer centralServer;
private EmergencyServer emergencyServer;
Expand Down Expand Up @@ -136,10 +141,31 @@ public void verifyPoliceWasNotCalled() {
assertFalse(EmergencyServer.called);
}

public void verifyAlarmLogIsEmpty() {
String log = getAlarmLog();
assertTrue(log.contains(EMPTY_LOG_NOTICE));
}

public void verifyAlarmLogContainsIntrusionAlarm() {
String log = getAlarmLog();
assertTrue(log.contains(LOG_INTRUSION_NOTICE));
}

public void verifyAlarmLogContainsFireAlarm() {
String log = getAlarmLog();
assertTrue(log.contains(LOG_FIRE_NOTICE));
}

public void setReceivedCallToFalse() {
EmergencyServer.called = false;
}

private String getAlarmLog() {
String log = "";
// TODO
return log;
}

public static Callable<Boolean> emergencyServerWasCalled() {
return new Callable<Boolean>() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;

import ca.ulaval.glo4002.centralServer.treatment.AlarmListTreatment;
import ca.ulaval.glo4002.centralServer.treatment.AlarmLogTreatment;

@Path("/alarm/")
public class AlarmListResource {

private static final int RESPONSE_OK = 200;

private AlarmListTreatment alarmListTreatment = new AlarmListTreatment();
private AlarmLogTreatment alarmListTreatment = new AlarmLogTreatment();

@POST
@Path("{userID}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import ca.ulaval.glo4002.centralServer.user.UserDirectoryLocator;
import ca.ulaval.glo4002.centralServer.user.UserNotFoundException;

public class AlarmListTreatment {
public class AlarmLogTreatment {

protected UserDirectory userDirectory = UserDirectoryLocator.getInstance().getUserDirectory();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class AlarmListTreatmentTest {
private UserDirectory userDirectory;

@InjectMocks
private AlarmListTreatment alarmListTreatment;
private AlarmLogTreatment alarmListTreatment;

@Before
public void setUp() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ private enum StatusType {
private boolean ready = true;
private DelayTimer delayTimer = new DelayTimer(this);

public AlarmSystem() {}

public boolean validatePIN(String typedPIN) {
return (isValidPIN(typedPIN) || RAPID_PIN == typedPIN);
}
Expand Down

0 comments on commit 46bc538

Please sign in to comment.