Skip to content

Commit

Permalink
Merge pull request #80 from mlee97/Tests
Browse files Browse the repository at this point in the history
#41 Refactor
  • Loading branch information
KaylaCharky authored Dec 7, 2020
2 parents 7d7bb8d + 6f56d35 commit 224bceb
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 38 deletions.
Binary file added Diagrams/Class Diagram Delivery 3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Diagrams/Package model.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions model.uml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<Diagram>
<ID>JAVA</ID>
<OriginalElement>smarthomesimulator.model</OriginalElement>
<nodes>
<node x="917.0" y="0.0">smarthomesimulator.model.SHP</node>
<node x="0.0" y="999.0">smarthomesimulator.model.Zone</node>
<node x="0.0" y="752.0">smarthomesimulator.model.Door</node>
<node x="662.0" y="252.0">smarthomesimulator.model.Profile.Role</node>
<node x="963.0" y="752.0">smarthomesimulator.model.Light</node>
<node x="384.0" y="752.0">smarthomesimulator.model.RoomTest</node>
<node x="0.0" y="0.0">smarthomesimulator.model.Simulator</node>
<node x="636.0" y="0.0">smarthomesimulator.model.Profile</node>
<node x="686.0" y="752.0">smarthomesimulator.model.ConsoleOutput</node>
<node x="369.0" y="0.0">smarthomesimulator.model.Room</node>
<node x="192.0" y="752.0">smarthomesimulator.model.Window</node>
</nodes>
<notes />
<edges>
<edge source="smarthomesimulator.model.Profile.Role" target="smarthomesimulator.model.Profile">
<point x="0.0" y="-125.5" />
<point x="0.0" y="101.0" />
</edge>
</edges>
<settings layout="Hierarchic Group" zoom="1.0" x="540.5" y="387.5" />
<SelectedNodes>
<node>smarthomesimulator.model.SHP</node>
</SelectedNodes>
<Categories>
<Category>Inner Classes</Category>
<Category>Properties</Category>
<Category>Methods</Category>
<Category>Constructors</Category>
<Category>Fields</Category>
</Categories>
<SCOPE>All</SCOPE>
<VISIBILITY>private</VISIBILITY>
</Diagram>

Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
package smarthomesimulator;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import smarthomesimulator.model.*;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
Expand Down Expand Up @@ -422,6 +415,4 @@ public Simulator getTemps(){
Simulator sim = simulatorMap.get(0);
return sim;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public ModelAndView showForm() {
}

@RequestMapping(value = "/simulator", method = {RequestMethod.GET, RequestMethod.POST})
public String submit(@Validated @ModelAttribute("simulator") Simulator simulator, @Validated @ModelAttribute("profile") Profile profile, @Validated @ModelAttribute("shp") SHP shp,
BindingResult result, ModelMap model, @RequestParam("file") String fileName) {
public String simulator(@Validated @ModelAttribute("simulator") Simulator simulator, @Validated @ModelAttribute("profile") Profile profile, @Validated @ModelAttribute("shp") SHP shp,
BindingResult result, ModelMap model, @RequestParam("file") String fileName) {
if (result.hasErrors()) {
return "error";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package smarthomesimulator.interfaces;

public interface Observable {

public void attachObserver(Observer o);
public void detachObserver(Observer o);
public void notifyObserver(Observable observable);
void notifyObserver(Observable observable);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package smarthomesimulator.interfaces;

public interface Observer {
public void update(Observable o);
void update(Observable o);
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,35 @@ public static void parse(String fileName) throws IOException {
Pattern patternLights = Pattern.compile("Lights:(.*?);");
Matcher matcherLights = patternLights.matcher(line);

if (matcherRoomName.find()) {
int numOfDoors = 0;
int numOfWindows = 0;
int numOfLights = 0;
matchRooms(matcherRoomName, matcherDoors, matcherWindows, matcherLights);
}
br.close();
}

String roomName = matcherRoomName.group(1);
private static void matchRooms(Matcher matcherRoomName, Matcher matcherDoors, Matcher matcherWindows, Matcher matcherLights) {
if (matcherRoomName.find()) {
int numOfDoors = 0;
int numOfWindows = 0;
int numOfLights = 0;

if (matcherDoors.find()) {
numOfDoors = (Integer.parseInt(matcherDoors.group(1)));
}
String roomName = matcherRoomName.group(1);

if (matcherWindows.find()) {
numOfWindows = (Integer.parseInt(matcherWindows.group(1)));
}
if (matcherDoors.find()) {
numOfDoors = (Integer.parseInt(matcherDoors.group(1)));
}

if (matcherLights.find()) {
numOfLights = ((Integer.parseInt(matcherLights.group(1))));
}

Room room = new Room(roomName, numOfDoors, numOfWindows,numOfLights);
if (matcherWindows.find()) {
numOfWindows = (Integer.parseInt(matcherWindows.group(1)));
}

Simulator.roomsOfHouse.add(room);
if (matcherLights.find()) {
numOfLights = ((Integer.parseInt(matcherLights.group(1))));
}

Room room = new Room(roomName, numOfDoors, numOfWindows,numOfLights);
Simulator.roomsOfHouse.add(room);
}
br.close();
}


}
2 changes: 0 additions & 2 deletions smart-home-simulator/src/main/resources/static/js/shhTab.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ void openCloseWindowsTest() {
}

@Test
void getBlockedDoors() {
void blockingDoorsTest() {
room.setBlockedDoors(1);
Assertions.assertEquals(room.getBlockedDoors(), 1);
}

@Test
void getBlockedWindows() {
void blockingWindowsTest() {
room.setBlockedWindows(1);
Assertions.assertEquals(room.getBlockedWindows(), 1);
}
Expand Down

0 comments on commit 224bceb

Please sign in to comment.