1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-12-08 12:01:09 +01:00

Re-work ad-hoc command (XEP-0050) implementation

Fixes SMACK-933.
This commit is contained in:
Florian Schmaus 2023-12-05 19:16:32 +01:00
parent dac06b04c3
commit 2337a446a5
21 changed files with 2062 additions and 1232 deletions

View file

@ -23,7 +23,6 @@ import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smackx.commands.AdHocCommand;
import org.jivesoftware.smackx.commands.packet.AdHocCommandData;
import org.junit.jupiter.api.Test;
@ -41,7 +40,7 @@ public class CommandsProviderTest {
final AdHocCommandData adHocIq = (AdHocCommandData) requestStanza;
assertEquals(IQ.Type.error, adHocIq.getType());
assertEquals(AdHocCommand.Action.execute, adHocIq.getAction());
assertEquals(AdHocCommandData.Action.execute, adHocIq.getAction());
StanzaError error = adHocIq.getError();
assertEquals(StanzaError.Type.CANCEL, error.getType());

View file

@ -0,0 +1,44 @@
/**
*
* Copyright 2024 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smackx.xdata.form;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.junit.jupiter.api.Test;
public class FillableFormTest {
@Test
public void testThrowOnIncompleteyFilled() {
FormField fieldA = FormField.textSingleBuilder("a").setRequired().build();
FormField fieldB = FormField.textSingleBuilder("b").setRequired().build();
DataForm form = DataForm.builder(DataForm.Type.form)
.addField(fieldA)
.addField(fieldB)
.build();
FillableForm fillableForm = new FillableForm(form);
fillableForm.setAnswer("a", 42);
IllegalStateException ise = assertThrows(IllegalStateException.class, () -> fillableForm.getSubmitForm());
assertTrue(ise.getMessage().startsWith("Not all required fields filled. "));
}
}