@Test public void shouldReturnFailedIfAttributeWithWrongTypeExists() { given(connector.getBody()).willReturn("{\"awesome_field\": true}"); ExecuteResult result = c.execute(connector); assertEquals(ExecuteResult.FAILED, result); }
@Test public void shouldReturnOkIfAttributeWithRightTypeExists() { given(connector.getBody()) .willReturn("{\"awesome_field\": \"Lorem Ipsum. Hello World! Fooooobar\"}"); ExecuteResult result = c.execute(connector); assertEquals(ExecuteResult.OK, result); }
@Test public void shouldReturnFailedIfAttributeDoesNotExist() { given(connector.getBody()) .willReturn("{\"not_so_awesome_field\": \"Lorem Ipsum. Hello World! Fooooobar\"}"); ExecuteResult result = c.execute(connector); assertEquals(ExecuteResult.FAILED, result); }
@Test public void shouldReturnOkIfAttributeWithRightTypeExistsWithComplexStructure() { given(connector.getBody()) .willReturn( "{\"awesome_field\": {\"foo\": \"Fooooobar.\"," + "\"other\": [\"Lorem Ipsum.\", \"Hello World!\"]}}"); c.setAttribute("awesome_field.foo"); ExecuteResult result = c.execute(connector); assertEquals(ExecuteResult.OK, result); }