daniLOLZ / ingsw2022-AM45

Progetto ingegneria del software 2022 Gruppo AM45
5 stars 0 forks source link

pls explain cast or fix getter. #13

Open ingconti opened 2 years ago

ingconti commented 2 years ago

I see:

obj = turnOrderList.get(position); turn =(long) obj; obj = stepsList.get(position); steps = (long) obj; why cast?

ghost commented 2 years ago

We removed the inappropriate cast, following a reevaluation of the creation of the assitant cards. It was used because of inexperience with the json format

ingconti commented 2 years ago

pls write here test cases You wrote for JSON

ghost commented 2 years ago

Good morning, after learning how the json syntax works we wrote test cases for other parts of the application related to json The following is one of them, found in the file BrokerTest.java This test uses some custom methods to read the json string

public void deserializeTest(){
        InputStream stream = createJSONFile("""
                {
                    "COMMAND" : "CONNECTION_REQUEST",
                    "NICKNAME" : "gigio"
                }""");
        try{
            broker.receive(stream);
        }
        catch (IOException e){
            //null
        }
        try {
            broker.waitSyncMessage();
        } catch (InterruptedException e) {
            fail();
        }
        assertEquals(CommandEnum.fromObjectToEnum(broker.readField(NetworkFieldEnum.COMMAND)), CommandEnum.CONNECTION_REQUEST);
        assertEquals((String)broker.readField(NetworkFieldEnum.NICKNAME), "gigio");
        broker.flushFirstSyncMessage();
    }