/** * Test for method {@link ParameterOperation#extractMowsParameters(String, String, MowField)} . * * @throws ClientMowException */ @Test public void testExtractMowsParametersOk() throws ClientMowException { final MowField resultField = DataGenerator.generateDefaultMowField(5, 5); final MowsParameters resultMowsParameters = new MowsParameters(); final MowParameters resultMowParameters1 = new MowParameters(1, 0, EnumDirection.N); final Actions actions1 = new Actions(); actions1.getList().add(EnumAction.D); actions1.getList().add(EnumAction.A); resultMowParameters1.setMowField(resultField); resultMowParameters1.setActions(actions1); final MowParameters resultMowParameters2 = new MowParameters(5, 0, EnumDirection.S); final Actions actions2 = new Actions(); actions2.getList().add(EnumAction.G); actions2.getList().add(EnumAction.A); resultMowParameters2.setMowField(resultField); resultMowParameters2.setActions(actions2); resultMowsParameters.getList().add(resultMowParameters1); resultMowsParameters.getList().add(resultMowParameters2); final String moveMessage = "5 5\n1 0 N\nDA\n5 0 S\nGA\n"; MowsParameters mowParameters = parameterOperation.extractMowsParameters( moveMessage, DataGenerator.generateDefaultMowField(5, 5)); Assert.assertEquals(resultMowsParameters, mowParameters); }
/** * Test for method {@link ParameterOperation#extractMowParameters(String, String, MowField)} . * * @throws ClientMowException */ @Test public void testExtractMowParametersOk() { final MowParameters resultParameters = new MowParameters(1, 0, EnumDirection.N); final Actions actions = new Actions(); actions.getList().add(EnumAction.D); resultParameters.setActions(actions); resultParameters.setMowField(DataGenerator.generateDefaultMowField(5, 5)); final String mowPosition = "1 0 N"; final String mowAction = "D"; final MowParameters mowParameters = parameterOperation.extractMowParameters( mowPosition, mowAction, DataGenerator.generateDefaultMowField(5, 5)); Assert.assertEquals(resultParameters, mowParameters); }
/** * Test for method {@link ParameterOperation#extractMowsParameters(String, String, MowField)} . * * @throws ClientMowException */ @Test(expected = ClientMowException.class) public void testExtractMowsParametersWithoutActionKo() throws ClientMowException { final String moveMessage = "1 0 N\n\n"; parameterOperation.extractMowsParameters( moveMessage, DataGenerator.generateDefaultMowField(5, 5)); }
/** * Test for method {@link ParameterOperation#getParamaters(String)}. * * @throws ClientMowException */ @Test public void testGetParamaters() throws ClientMowException { String move = "5 5\n1 0 N\nD\n"; // Field MowField resultField = DataGenerator.generateDefaultMowField(5, 5); // Mower MowsParameters resultsPositions = new MowsParameters(); MowParameters resultParameters = new MowParameters(1, 0, EnumDirection.N); Actions actions = new Actions(); actions.getList().add(EnumAction.D); resultParameters.setMowField(resultField); resultParameters.setActions(actions); resultsPositions.getList().add(resultParameters); MowsParameters parameters = parameterOperation.getParamaters(move); Assert.assertEquals(resultsPositions, parameters); }