Update wiki to match gradle conversion authored by Derek Williams's avatar Derek Williams
...@@ -6,37 +6,37 @@ To start the code that interacts with the database is split into three parts: ...@@ -6,37 +6,37 @@ To start the code that interacts with the database is split into three parts:
* A mock gateway * A mock gateway
* An RDS gateway * An RDS gateway
All of which are in the GameServer/src/datasource package with the same prefix, ie `NPCQuestionRowDataGateway`, `NPCQuestionRowDataGatewayMock`, and `NPCQuestionRowDataGatewayRDS` All of which are in the GameServer/src/main/java/datasource package with the same prefix, ie `NPCQuestionRowDataGateway`, `NPCQuestionRowDataGatewayMock`, and `NPCQuestionRowDataGatewayRDS`
The interface defines the methods that will be available to access the database. The Mock acts as the database in most tests. The RDS talks to the actual database hosted on Amazon's Web Services which is used when the game is being played and in the RDS tests. The interface defines the methods that will be available to access the database. The Mock acts as the database in most tests. The RDS talks to the actual database hosted on Amazon's Web Services which is used when the game is being played and in the RDS tests.
#### Test files #### Test files
As for the tests, they follow essentially the same pattern, but with a small difference. In the tests you may notice that the base class is now an abstract class and not an interface. This allows us to only modify one test file and have both the Mock and RDS gateways be tested the same way. For the Mock and RDS versions of the test files you should not have to change anything, all they do is setup the gateway for the test. As for the tests, they follow essentially the same pattern, but with a small difference. In the tests you may notice that the base class is now an abstract class and not an interface. This allows us to only modify one test file and have both the Mock and RDS gateways be tested the same way. For the Mock and RDS versions of the test files you should not have to change anything, all they do is setup the gateway for the test.
There is one small caveat about running the tests however, you cannot run any specific test in the base test class, or the base test class at all. You have to right click on the mock or RDS test file and run it as a JUnit test there due to the inheritance. There is one small caveat about running the tests however, you cannot run any specific test in the base test class, or the base test class at all. You have to right click on the mock or RDS test file and run it as a JUnit test there due to the inheritance.
#### Test data #### Test data
In addition to the tests there are also a couple of enums located in either GameServer/tests/testData/ (This one only contains data used by the area servers) or in GameShared/tests/testData/ (This one contains data used by both the area servers and the login server). These enums contain the test data for the tests and (when it's pushed, which is mentioned a little later) for the game when it's in testing mode (this is the default mode you use). In order to push these changes to the database you will have to use one of the programs in GameServer/tests/default package, GameShared/tests/default package, or LoginServer/tests/default package. These will drop the corresponding database tables, create the tables, and insert the data into them. In addition to the tests there are also a couple of enums located in either GameServer/src/main/java/datatypes (This one only contains data used by the area servers) or in GameShared/src/main/java/datatypes (This one contains data used by both the area servers and the login server). These enums contain the test data for the tests and (when it's pushed, which is mentioned a little later) for the game when it's in testing mode (this is the default mode you use). In order to push these changes to the database you will have to use one of the programs in GameServer/src/test/java/default package, GameShared/src/test/java/default package, or LoginServer/src/test/java/default package. These will drop the corresponding database tables, create the tables, and insert the data into them.
## The Mock Gateway ## The Mock Gateway
#### Basic information #### Basic information
To change something in the database the first step is to make the change in the mock gateway. For this step there are 3 or 4 main files you need to modify, the mock gateway, the mock gateway test, the interface if you're adding or deleting a method, and the enum that holds the mock data for tests. To change something in the database the first step is to make the change in the mock gateway. For this step there are 3 or 4 main files you need to modify, the mock gateway, the mock gateway test, the interface if you're adding or deleting a method, and the enum that holds the mock data for tests.
#### Mock Gateway #### Mock Gateway
For the mock gateway file you need to make whatever change you need, this file is fairly standard to change the only thing to watch out for is if there is a container class within the mock class such as in `NPCQuestionRowDataGatewayMock` which has the `NPCQuestionInfo` class. For this class you need to make sure the field is added to the instance variable list, the constructor, and a getter for it is added also. If you remove a field you have to go through the same procedure, but with removing that field instead of adding it. For the mock gateway file you need to make whatever change you need, this file is fairly standard to change the only thing to watch out for is if there is a container class within the mock class such as in `NPCQuestionRowDataGatewayMock` which has the `NPCQuestionInfo` class. For this class you need to make sure the field is added to the instance variable list, the constructor, and a getter for it is added also. If you remove a field you have to go through the same procedure, but with removing that field instead of adding it.
#### Tests #### Tests
For the mock gateway test you need to make sure to update the finder test to make sure the data can be retrieved from the gateway and add or modify any other test methods you need for whatever is being modified in the mock (If you are only adding or removing a field you should only have to modify the finder method). For the mock gateway test you need to make sure to update the finder test to make sure the data can be retrieved from the gateway and add or modify any other test methods you need for whatever is being modified in the mock (If you are only adding or removing a field you should only have to modify the finder method).
#### Testdata #### Test Enums
In some test methods you may notice we're using a couple of enums for the tests. If you're adding, removing, or modifying a field you will have to make that same change to every entry in the corresponding enum. For example if you're trying to add a field to the `NPCQuestionRowDataGatewayMock` you will have to add that field to every entry in the NPCQuestionsForTest file. All of these enums can be found in either GameServer/tests/testData/ or in GameShared/tests/testData/. Depending on the change it is usually a good idea to make one or more entries for the purposes of testing that functionality, this way you have a smaller chance of breaking existing tests. In some test methods you may notice we're using a couple of enums for the tests. If you're adding, removing, or modifying a field you will have to make that same change to every entry in the corresponding enum. For example if you're trying to add a field to the `NPCQuestionRowDataGatewayMock` you will have to add that field to every entry in the NPCQuestionsForTest file. All of these enums can be found in either GameServer/src/main/java/datatypes or in GameShared/src/main/java/datatypes. Depending on the change it is usually a good idea to make one or more entries for the purposes of testing that functionality, this way you have a smaller chance of breaking existing tests.
## The RDS Gateway ## The RDS Gateway
...@@ -47,6 +47,6 @@ Once you have the tests working for the mock gateway you can make the necessary ...@@ -47,6 +47,6 @@ Once you have the tests working for the mock gateway you can make the necessary
* The insert statement * The insert statement
* At least one select statement * At least one select statement
This should look pretty familiar from the databases class. You need to add the field and it's correct datatype to the create table statement, add it to the insert, and make sure it's being set in the select statement. If you have any other functionality be sure to add it wherever it's appropriate This should look pretty familiar from the databases class. You need to add the field and it's correct datatype to the create table statement, add it to the insert, and make sure it's being set in the select statement. If you have any other functionality be sure to add it wherever it's appropriate
After you do that, run the tests and it should go green. After you do that, run the tests and it should go green.
\ No newline at end of file