GithubHelp home page GithubHelp logo

Comments (11)

lordofthejars avatar lordofthejars commented on June 29, 2024

Jérémy I have tried to import next json file as pakko suggested but completing with missing information and the exception was thrown.

{
   "name":"",
   "replicationFactor":"",
   "strategy":"",
   "columnFamilies":[
      {
         "name":"at_workreq",
         "type":"STANDARD",
         "keyType":"TimeUUIDType",
         "comparatorType":"UTF8Type",
         "defaultColumnValueType":"UTF8Type",
         "rows":[
            {
               "key":"989C6E5C-2CC1-11CA-A044-08002B1BB4F5",
               "columns":[
                  {
                     "name":"WORKREQUEST",
                     "value":[
                        {
                           "name":"device",
                           "value":"989C6E5C-2CC1-11CA-A044-08002B1BB4F6"
                        },
                        {
                           "name":"timeuuid",
                           "value":"989C6E5C-2CC1-11CA-A044-08002B1BB4F5"
                        },
                        {
                           "name":"workReqTargetList",
                           "value":[
                              {
                                 "name":"name",
                                 "value":"989C6E5C-2CC1-11CA-A044-08002B1BB4F6"
                              },
                              {
                                 "name":"cfgGUID",
                                 "value":"cfgGUID"
                              },
                              {
                                 "name":"fwGUID",
                                 "value":"firmwareGUID"
                              },
                              {
                                 "name":"cpu",
                                 "value":"90.0"
                              }
                           ]
                        }
                     ]
                  }
               ]
            }
         ]
      }
   ]
}

in this case I am going to close the issue opened in nosqlunit about the same thing. If you plan to fix this problem, we can stay connected because I will need to make some modifications too.

from cassandra-unit.

jsevellec avatar jsevellec commented on June 29, 2024

Hi,

as defined in the dataSet you attached, the defaut type for column value is set to utf8 type. So you just have to make a valid string containing a valid json inside.
So :

  • surround the json with double quote
  • replace inside the json string the double quote with simple quote

it will give something like hat :

    "name":"blabla",
    "columnFamilies":[
        {
            "name":"at_workreq",
            "type":"STANDARD",
            "keyType":"TimeUUIDType",
            "comparatorType":"UTF8Type",
            "defaultColumnValueType":"UTF8Type",
            "rows":[
                {
                    "key":"989C6E5C-2CC1-11CA-A044-08002B1BB4F5",
                    "columns":[
                        {
                            "name":"WORKREQUEST",
                            "value":"[{'name':'device','value':'989C6E5C-2CC1-11CA-A044-08002B1BB4F6'},{'name':'timeuuid','value':'989C6E5C-2CC1-11CA-A044-08002B1BB4F5'},{'name':'workReqTargetList','value':[{'name':'name','value':'989C6E5C-2CC1-11CA-A044-08002B1BB4F6'},{'name':'cfgGUID','value':'cfgGUID'},{'name':'fwGUID','value':'firmwareGUID'},{'name':'cpu','value':'90.0'}]}]"
                        }
                    ]
                }
            ]
        }
    ]
}

from cassandra-unit.

lordofthejars avatar lordofthejars commented on June 29, 2024

yes you are right I have not seen this as a simple json string, I suppose that pakko means this approach too and I have been confused with some kind of recursive values. Well inthis case all works perfectly, cassandra unit and nosqlunit.

Thanks.

from cassandra-unit.

jsevellec avatar jsevellec commented on June 29, 2024

right. @pakko , tell me if it's ok for you.

from cassandra-unit.

pakko avatar pakko commented on June 29, 2024

Thanks Jérémy, after revise my test data as your suggestion, it will not throw parser error exception, but a NoSqlAssertion error, maybe it is nosqlunit issue

from cassandra-unit.

jsevellec avatar jsevellec commented on June 29, 2024

nice :-)

from cassandra-unit.

lordofthejars avatar lordofthejars commented on June 29, 2024

you are right, now the problem is in NoSQLUnit, I will take a look, and see what is returned in each case, I will use the Jérémy approach to test it.

from cassandra-unit.

pakko avatar pakko commented on June 29, 2024

BTW, when I use expected_workrequest.json as I pasted in @UsingDataSet annotation, it will throw such exception
java.lang.RuntimeException: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2
at com.cisco.onplus.das.server.dao.monitoring.MonitoringNoSQLDao.queryDeviceResponseDataById(MonitoringNoSQLDao.java:1017)
at com.cisco.onplus.das.server.dao.monitoring.MonitoringNoSQLDao.getDeviceResponseById(MonitoringNoSQLDao.java:983)
at com.cisco.onplus.das.server.dao.monitoring.MonitoringNoSQLDaoRemoteCassandraTest.testGetDeviceResponseById_WorkRequest(MonitoringNoSQLDaoRemoteCassandraTest.java:404)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at com.lordofthejars.nosqlunit.core.AbstractNoSqlTestRule$1.evaluate(AbstractNoSqlTestRule.java:72)
at org.junit.rules.RunRules.evaluate(RunRules.java:18)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:176)
at com.google.gson.Gson.fromJson(Gson.java:791)
at com.google.gson.Gson.fromJson(Gson.java:757)
at com.google.gson.Gson.fromJson(Gson.java:706)
at com.google.gson.Gson.fromJson(Gson.java:678)
at com.cisco.onplus.das.server.dao.monitoring.NosqlJsonConverter.formulateObject(NosqlJsonConverter.java:29)
at com.cisco.onplus.das.server.dao.monitoring.MonitoringNoSQLDao.queryDeviceResponseDataById(MonitoringNoSQLDao.java:1009)
... 28 more
Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2
at com.google.gson.stream.JsonReader.expect(JsonReader.java:339)
at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:322)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:165)
... 34 more

from cassandra-unit.

lordofthejars avatar lordofthejars commented on June 29, 2024

I think that problem is in your DAO in this case because I think you are using gson as parser in com.cisco.onplus.das.server.dao.monitoring.MonitoringNoSQLDao.queryDeviceResponseDataById(MonitoringNoSQLDao.java:1017) throws an exception of invalid json entry, nothing to related with cassandraunit nor nosqlunit.

from cassandra-unit.

pakko avatar pakko commented on June 29, 2024

Thanks, I will check it

from cassandra-unit.

lordofthejars avatar lordofthejars commented on June 29, 2024

Ok, this afternoon I will check nosqlunit too using " approach.

from cassandra-unit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.