QQQ-16 some cleanup and increased test cover

This commit is contained in:
2022-06-23 16:41:05 -05:00
parent 68b33cf36b
commit b809a43b6c
7 changed files with 302 additions and 11 deletions

View File

@ -0,0 +1,58 @@
/*
* QQQ - Low-code Application Framework for Engineers.
* Copyright (C) 2021-2022. Kingsrook, LLC
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
* contact@kingsrook.com
* https://github.com/Kingsrook/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.kingsrook.qqq.backend.core.callbacks;
import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import com.kingsrook.qqq.backend.core.model.actions.query.QQueryFilter;
import com.kingsrook.qqq.backend.core.model.metadata.QFieldMetaData;
/*******************************************************************************
** Simple implementation of a callback, that does no-op (returns empty objects).
** Useful for scaffolding, perhaps tests.
*******************************************************************************/
public class NoopCallback implements QProcessCallback
{
/*******************************************************************************
** Get the filter query for this callback.
*******************************************************************************/
@Override
public QQueryFilter getQueryFilter()
{
return (new QQueryFilter());
}
/*******************************************************************************
** Get the field values for this callback.
*******************************************************************************/
@Override
public Map<String, Serializable> getFieldValues(List<QFieldMetaData> fields)
{
return (Collections.emptyMap());
}
}

View File

@ -22,6 +22,7 @@
package com.kingsrook.qqq.backend.core.model.metadata;
import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;
@ -30,7 +31,7 @@ import java.util.Map;
** Meta-Data to define a table in a QQQ instance.
**
*******************************************************************************/
public class QTableMetaData
public class QTableMetaData implements Serializable
{
private String name;
private String label;

View File

@ -27,18 +27,14 @@ import java.util.UUID;
import com.kingsrook.qqq.backend.core.model.session.QSession;
import com.kingsrook.qqq.backend.core.model.session.QUser;
import com.kingsrook.qqq.backend.core.modules.interfaces.QAuthenticationModuleInterface;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/*******************************************************************************
**
** An authentication module with no actual backing system - all users are treated
** as anonymous, and all sessions are always valid.
*******************************************************************************/
public class FullyAnonymousAuthenticationModule implements QAuthenticationModuleInterface
{
private static final Logger logger = LogManager.getLogger(FullyAnonymousAuthenticationModule.class);
/*******************************************************************************
**
@ -51,7 +47,7 @@ public class FullyAnonymousAuthenticationModule implements QAuthenticationModule
qUser.setFullName("Anonymous");
QSession qSession = new QSession();
if (context.get("sessionId") != null)
if(context != null && context.get("sessionId") != null)
{
qSession.setIdReference(context.get("sessionId"));
}
@ -72,6 +68,10 @@ public class FullyAnonymousAuthenticationModule implements QAuthenticationModule
@Override
public boolean isSessionValid(QSession session)
{
if(session == null)
{
return (false);
}
return (true);
}
}

View File

@ -23,6 +23,7 @@ package com.kingsrook.qqq.backend.core.state;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Serializable;
import com.kingsrook.qqq.backend.core.utils.JsonUtils;
@ -30,7 +31,7 @@ import org.apache.commons.io.FileUtils;
/*******************************************************************************
** Singleton class that provides a (non-persistent!!) in-memory state provider.
** State provider that uses files in the /tmp/ directory.
*******************************************************************************/
public class TempFileStateProvider implements StateProviderInterface
{
@ -92,9 +93,9 @@ public class TempFileStateProvider implements StateProviderInterface
String json = FileUtils.readFileToString(new File("/tmp/" + key.toString()));
return JsonUtils.toObject(json, type);
}
catch(ClassCastException cce)
catch(FileNotFoundException fnfe)
{
throw new RuntimeException("Stored state value could not be cast to desired type", cce);
return (null);
}
catch(IOException ie)
{