Search in sources :

Example 1 with NoAuthenticatorDefinition

use of com.thecoderscorner.menu.editorui.generator.parameters.auth.NoAuthenticatorDefinition in project tcMenu by davetcc.

the class AuthenticatorDefinition method readFromProject.

static AuthenticatorDefinition readFromProject(String encoding) {
    if (StringHelper.isStringEmptyOrNull(encoding))
        return new NoAuthenticatorDefinition();
    try {
        if (encoding.startsWith("rom:")) {
            var entries = encoding.split(":");
            if (entries.length != 3)
                return new NoAuthenticatorDefinition();
            int offset = Integer.parseInt(entries[1]);
            int numRemotes = Integer.parseInt(entries[2]);
            return new EepromAuthenticatorDefinition(offset, numRemotes);
        } else if (encoding.startsWith("flash:")) {
            var remoteIds = encoding.split(":");
            int current = 2;
            var remoteList = new ArrayList<FlashRemoteId>();
            while ((current + 1) < remoteIds.length) {
                remoteList.add(new FlashRemoteId(remoteIds[current], remoteIds[current + 1]));
                current += 2;
            }
            return new ReadOnlyAuthenticatorDefinition(remoteIds[1], remoteList);
        } else
            return new NoAuthenticatorDefinition();
    } catch (Exception ex) {
        return new NoAuthenticatorDefinition();
    }
}
Also used : ReadOnlyAuthenticatorDefinition(com.thecoderscorner.menu.editorui.generator.parameters.auth.ReadOnlyAuthenticatorDefinition) EepromAuthenticatorDefinition(com.thecoderscorner.menu.editorui.generator.parameters.auth.EepromAuthenticatorDefinition) NoAuthenticatorDefinition(com.thecoderscorner.menu.editorui.generator.parameters.auth.NoAuthenticatorDefinition)

Example 2 with NoAuthenticatorDefinition

use of com.thecoderscorner.menu.editorui.generator.parameters.auth.NoAuthenticatorDefinition in project tcMenu by davetcc.

the class FileBasedProjectPersistorTest method testSaveThenLoad.

@Test
public void testSaveThenLoad() throws IOException {
    Path projFile = dir.resolve("projectSave.emf");
    FileBasedProjectPersistor persistor = new FileBasedProjectPersistor();
    MenuTree tree = TestUtils.buildCompleteTree();
    List<String> remoteUuids = List.of("uuid3");
    List<CreatorProperty> propsList = Collections.singletonList(new CreatorProperty("name", "desc", "extra desc", "123", DISPLAY, CreatorProperty.PropType.USE_IN_DEFINE, CannedPropertyValidators.textValidator(), new AlwaysApplicable()));
    var options = new CodeGeneratorOptionsBuilder().withPlatform(ARDUINO_AVR.getBoardId()).withDisplay("uuid1").withInput("uuid2").withTheme("uuid4").withRemotes(remoteUuids).withProperties(propsList).withAppName("app name").withNewId(APPLICATION_UUID).withEepromDefinition(new NoEepromDefinition()).withAuthenticationDefinition(new NoAuthenticatorDefinition()).withExpanderDefinitions(new IoExpanderDefinitionCollection()).codeOptions();
    persistor.save(projFile.toString(), "", tree, options);
    MenuTreeWithCodeOptions openResult = persistor.open(projFile.toString());
    compareTrees(tree, openResult.getMenuTree());
    assertEquals(ARDUINO_AVR.getBoardId(), openResult.getOptions().getEmbeddedPlatform());
    assertEquals("uuid1", openResult.getOptions().getLastDisplayUuid());
    assertEquals("uuid2", openResult.getOptions().getLastInputUuid());
    assertEquals("uuid3", openResult.getOptions().getLastRemoteCapabilitiesUuids().get(0));
    assertEquals("app name", openResult.getOptions().getApplicationName());
    assertEquals("app name", openResult.getOptions().getApplicationName());
    assertEquals(APPLICATION_UUID, openResult.getOptions().getApplicationUUID());
    List<CreatorProperty> returnedProps = openResult.getOptions().getLastProperties();
    assertEquals("123", returnedProps.get(0).getLatestValue());
    assertEquals("name", returnedProps.get(0).getName());
    assertEquals(DISPLAY, returnedProps.get(0).getSubsystem());
}
Also used : Path(java.nio.file.Path) MenuTree(com.thecoderscorner.menu.domain.state.MenuTree) NoEepromDefinition(com.thecoderscorner.menu.editorui.generator.parameters.eeprom.NoEepromDefinition) CreatorProperty(com.thecoderscorner.menu.editorui.generator.core.CreatorProperty) CodeGeneratorOptionsBuilder(com.thecoderscorner.menu.editorui.generator.CodeGeneratorOptionsBuilder) AlwaysApplicable(com.thecoderscorner.menu.editorui.generator.applicability.AlwaysApplicable) NoAuthenticatorDefinition(com.thecoderscorner.menu.editorui.generator.parameters.auth.NoAuthenticatorDefinition) IoExpanderDefinitionCollection(com.thecoderscorner.menu.editorui.generator.parameters.IoExpanderDefinitionCollection) Test(org.junit.jupiter.api.Test)

Aggregations

NoAuthenticatorDefinition (com.thecoderscorner.menu.editorui.generator.parameters.auth.NoAuthenticatorDefinition)2 MenuTree (com.thecoderscorner.menu.domain.state.MenuTree)1 CodeGeneratorOptionsBuilder (com.thecoderscorner.menu.editorui.generator.CodeGeneratorOptionsBuilder)1 AlwaysApplicable (com.thecoderscorner.menu.editorui.generator.applicability.AlwaysApplicable)1 CreatorProperty (com.thecoderscorner.menu.editorui.generator.core.CreatorProperty)1 IoExpanderDefinitionCollection (com.thecoderscorner.menu.editorui.generator.parameters.IoExpanderDefinitionCollection)1 EepromAuthenticatorDefinition (com.thecoderscorner.menu.editorui.generator.parameters.auth.EepromAuthenticatorDefinition)1 ReadOnlyAuthenticatorDefinition (com.thecoderscorner.menu.editorui.generator.parameters.auth.ReadOnlyAuthenticatorDefinition)1 NoEepromDefinition (com.thecoderscorner.menu.editorui.generator.parameters.eeprom.NoEepromDefinition)1 Path (java.nio.file.Path)1 Test (org.junit.jupiter.api.Test)1