Search in sources :

Example 11 with BasicGuidEntry

use of edu.umass.cs.gnsclient.client.util.BasicGuidEntry in project GNS by MobilityFirst.

the class SelectAutoGroupTest method test_559_QueryAlterGroup.

/**
   *
   */
@Test
public // Change all the testQuery fields except 1 to be equal to zero
void test_559_QueryAlterGroup() {
    try {
        JSONArray result = clientCommands.selectLookupGroupQuery(groupOneGuid.getGuid());
        // change ALL BUT ONE to be ZERO
        for (int i = 0; i < result.length() - 1; i++) {
            BasicGuidEntry guidInfo = new BasicGuidEntry(clientCommands.lookupGuidRecord(result.getString(i)));
            GuidEntry entry = GuidUtils.lookupGuidEntryFromDatabase(clientCommands, guidInfo.getEntityName());
            JSONArray array = new JSONArray(Arrays.asList(0));
            clientCommands.fieldReplaceOrCreateList(entry, groupTestFieldName, array);
        }
    } catch (ClientException | IOException | JSONException e) {
        Utils.failWithStackTrace("Exception while trying to alter the fields: " + e);
    }
}
Also used : BasicGuidEntry(edu.umass.cs.gnsclient.client.util.BasicGuidEntry) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) IOException(java.io.IOException) BasicGuidEntry(edu.umass.cs.gnsclient.client.util.BasicGuidEntry) GuidEntry(edu.umass.cs.gnsclient.client.util.GuidEntry) Test(org.junit.Test) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest)

Example 12 with BasicGuidEntry

use of edu.umass.cs.gnsclient.client.util.BasicGuidEntry in project GNS by MobilityFirst.

the class SelectAutoGroupTest method test_560_QueryLookupGroupAfterAlterations.

/**
   *
   */
@Test
public void test_560_QueryLookupGroupAfterAlterations() {
    try {
        JSONArray result = clientCommands.selectLookupGroupQuery(groupOneGuid.getGuid());
        // should only be one
        Assert.assertThat(result.length(), Matchers.equalTo(1));
        // look up the individual values
        for (int i = 0; i < result.length(); i++) {
            BasicGuidEntry guidInfo = new BasicGuidEntry(clientCommands.lookupGuidRecord(result.getString(i)));
            GuidEntry entry = GuidUtils.lookupGuidEntryFromDatabase(clientCommands, guidInfo.getEntityName());
            String value = clientCommands.fieldReadArrayFirstElement(entry, groupTestFieldName);
            Assert.assertEquals(TEST_HIGH_VALUE, value);
        }
    } catch (ClientException | IOException | JSONException e) {
        Utils.failWithStackTrace("Exception executing selectLookupGroupQuery: " + e);
    }
}
Also used : BasicGuidEntry(edu.umass.cs.gnsclient.client.util.BasicGuidEntry) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) RandomString(edu.umass.cs.gnscommon.utils.RandomString) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) IOException(java.io.IOException) BasicGuidEntry(edu.umass.cs.gnsclient.client.util.BasicGuidEntry) GuidEntry(edu.umass.cs.gnsclient.client.util.GuidEntry) Test(org.junit.Test) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest)

Example 13 with BasicGuidEntry

use of edu.umass.cs.gnsclient.client.util.BasicGuidEntry in project GNS by MobilityFirst.

the class SelectAutoGroupTest method test_551_QueryRemovePreviousTestFields.

/**
   *
   */
@Test
public void test_551_QueryRemovePreviousTestFields() {
    // find all the guids that have our field and remove it from them
    try {
        String query = "~" + groupTestFieldName + " : {$exists: true}";
        JSONArray result = clientCommands.selectQuery(query);
        for (int i = 0; i < result.length(); i++) {
            BasicGuidEntry guidInfo = new BasicGuidEntry(clientCommands.lookupGuidRecord(result.getString(i)));
            GuidEntry guidEntry = GuidUtils.lookupGuidEntryFromDatabase(clientCommands, guidInfo.getEntityName());
            System.out.println("Removing from " + guidEntry.getEntityName());
            clientCommands.fieldRemove(guidEntry, groupTestFieldName);
        }
    } catch (ClientException | IOException | JSONException e) {
        Utils.failWithStackTrace("Trying to remove previous test's fields: " + e);
    }
}
Also used : BasicGuidEntry(edu.umass.cs.gnsclient.client.util.BasicGuidEntry) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) RandomString(edu.umass.cs.gnscommon.utils.RandomString) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) IOException(java.io.IOException) BasicGuidEntry(edu.umass.cs.gnsclient.client.util.BasicGuidEntry) GuidEntry(edu.umass.cs.gnsclient.client.util.GuidEntry) Test(org.junit.Test) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest)

Aggregations

BasicGuidEntry (edu.umass.cs.gnsclient.client.util.BasicGuidEntry)13 GuidEntry (edu.umass.cs.gnsclient.client.util.GuidEntry)13 JSONArray (org.json.JSONArray)10 ClientException (edu.umass.cs.gnscommon.exceptions.client.ClientException)9 IOException (java.io.IOException)9 RandomString (edu.umass.cs.gnscommon.utils.RandomString)8 JSONException (org.json.JSONException)8 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)5 EncryptionException (edu.umass.cs.gnscommon.exceptions.client.EncryptionException)4 FieldNotFoundException (edu.umass.cs.gnscommon.exceptions.client.FieldNotFoundException)4 DefaultGNSTest (edu.umass.cs.gnsserver.utils.DefaultGNSTest)4 FileNotFoundException (java.io.FileNotFoundException)4 Test (org.junit.Test)4 GNSClientCommands (edu.umass.cs.gnsclient.client.GNSClientCommands)1 InvalidKeyException (java.security.InvalidKeyException)1 SignatureException (java.security.SignatureException)1 InvalidKeySpecException (java.security.spec.InvalidKeySpecException)1