Skip to main content

Issue with DocumentNoteTypes when testing

Comments

6 comments

  • Matthew Cheung

    Hi there,

    You can fix this by changing the 

    TestGeneious.initialize();

    to

    TestGeneious.initializePlugins("com.biomatters.plugins.local.LocalDatabasePlugin");

     

    It's not obvious so I can understand you missing it.  The problem is that using DocumentNoteTypes requires the local database to be initialized, otherwise it has no place to store the types (which are stored database wide).  

    0
  • Guzman

    Hello,

    Thanks for your answer. I've tried this but I still have the same issue. This is the code I run:

    @BeforeAll
    static void setUp() {
    TestGeneious.initializePlugins("com.biomatters.plugins.local.LocalDatabasePlugin");

    List<DocumentNoteField> fields = new ArrayList<>();
    fields.add(DocumentNoteField.createTextNoteField("Field no.1", "The first field", "fieldCode", Collections.emptyList(), true));
    DocumentNoteType noteType = DocumentNoteUtilities.createNewNoteType("Test note", "Test code", "Test description", fields, true);
    DocumentNoteUtilities.setNoteType(noteType);
    }

    And I get this error (seems like the same as before):


    java.lang.NullPointerException
        at com.biomatters.geneious.publicapi.documents.NoteTypeStorage.c(NoteTypeStorage.java:506)
        at com.biomatters.geneious.publicapi.documents.NoteTypeStorage.a(NoteTypeStorage.java:377)
        at com.biomatters.geneious.publicapi.documents.NoteTypeStorage.a(NoteTypeStorage.java:471)
        at com.biomatters.geneious.publicapi.documents.NoteTypeStorage.setNoteType(NoteTypeStorage.java:425)
        at com.biomatters.geneious.publicapi.documents.DocumentNoteUtilities.setNoteType(DocumentNoteUtilities.java:103)
        at com.biomatters.geneious.publicapi.documents.NoteTypeStorage.b(NoteTypeStorage.java:85)
        at com.biomatters.geneious.publicapi.documents.NoteTypeStorage.a(NoteTypeStorage.java:67)
        at com.biomatters.geneious.publicapi.documents.NoteTypeStorage.setNoteType(NoteTypeStorage.java:418)
      at com.biomatters.geneious.publicapi.documents.DocumentNoteUtilities.setNoteType(DocumentNoteUtilities.java:103

    Am I missing something? Thanks!

    0
  • Matthew Cheung

    Hmmm I'm not sure why it is still failing, perhaps it is version specific.  What version of Geneious / the plugin development kit are you using?

    I'm also happy to take a closer look at your code if you don't mind sharing it.  Please send it through to support@geneious.com and mention me if you're OK to do this.

    0
  • Guzman

    Hi,

    Not sure how to see the plugin dev kit version, but the Geneious version I'm using is:

    Build 2022-11-28 12:49
    Java Version 11.0.17+7-LTS (64 bit)

    As for sharing the code, I don't think I can do that, however, the example I shared before should be enough to reproduce it. It's the set up method of a JUnit test. 

    0
  • Matthew Cheung

    Ah I think I know what the issue might be.  

    What is the working directory for the test run?  If you're using our plugin development kit it needs to be set to the GeneiousFiles directory so that Geneious can find the LocalDatabasePlugin.

    0
  • Guzman

    That worked!

    Thanks!

    0

Please sign in to leave a comment.