-
Notifications
You must be signed in to change notification settings - Fork 4
added feature: if there's a config.xml add projects to database #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/test/java/configTest.xml
Outdated
| </project> | ||
|
|
||
| <project> | ||
| <name>Carl Zeiss</name> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use some other project name
| final String isWork = eElement.getElementsByTagName("isWork").item(0).getTextContent(); | ||
| final String color = eElement.getElementsByTagName("color").item(0).getTextContent(); | ||
|
|
||
| System.out.println("checking for: " + name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use a logger instead for sysout
| public class ConfigParser { | ||
|
|
||
| Controller controller; | ||
| Model model; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't use the model in the class - delete it
| private final ObservableList<Project> projects = FXCollections.observableArrayList(); | ||
|
|
||
| Model model = new Model(); | ||
| private final ObservableList<Project> spyModel = spy(model.availableProjects); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice :) But as we mock the Controller, we don't have to test if the controller writes the new projects into the model correctly. We should just make sure, that controller.addNewProject is called as often as we expect with the needed parameters So we could get rid of all references of the model.
| return f.exists(); | ||
| } | ||
|
|
||
| public void parserConfig(final File inputFile) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be renamed to parseConfig
|
|
||
| loadConfigFile(CONFIG_FILENAME); | ||
|
|
||
| verify(controller).addNewProject(eq("Carl Zeiss"), anyBoolean(), any(Color.class), anyInt()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there you should verify if the isWork, color, index are the ones you expect the loader to create (like with the name)
|
|
||
| loadConfigFile(CONFIG_FILENAME); | ||
|
|
||
| verify(controller, atLeastOnce()).addNewProject(eq("Peter Lustig"), anyBoolean(), any(Color.class), anyInt()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this would return true, if the addNewProjects was not called in this test, as it was called in another test before. As you use the same controller instance for all tests? I think you should create a new mock-controller for each test case e.g. with @before
| private final ObservableList<Project> spyModel = spy(model.availableProjects); | ||
| private final Controller controller = mock(Controller.class); | ||
|
|
||
| @Before |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
before is run before each single test. so after n tests there should be n*4 projects in the projects list. I guess that is not what you wanted :) beforeclass can be used in this case, where the method is called just once before all tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, junit '@test' annotation instatiates a new Object of your test class for each test :)
|
Also there should be some mechanism to ask the user if he wants to import the config, but not each time he starts the app :) |
…d press the button 'parse config.xml'
No description provided.