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();
}
}
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());
}
Aggregations