summaryrefslogtreecommitdiffstats
path: root/auth/auth-cass/src
diff options
context:
space:
mode:
Diffstat (limited to 'auth/auth-cass/src')
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/AbsCassDAO.java86
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Bytification.java4
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CIDAO.java10
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Cacheable.java8
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Cached.java28
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CachedDAO.java50
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassAccess.java26
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassDAOImpl.java34
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/DAO.java4
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/DAOException.java6
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/DAO_RO.java10
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Loader.java28
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Streamer.java4
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Touchable.java4
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedCertDAO.java12
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedCredDAO.java24
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedNSDAO.java4
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedPermDAO.java20
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedRoleDAO.java12
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedUserRoleDAO.java8
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/FileGetter.java202
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ApprovalDAO.java36
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ArtiDAO.java28
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CacheInfoDAO.java50
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CacheableData.java8
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CertDAO.java28
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ConfigDAO.java16
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CredDAO.java42
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/DelegateDAO.java20
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/FutureDAO.java14
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/HistoryDAO.java46
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/LocateDAO.java28
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/Namespace.java14
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsDAO.java68
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsSplit.java8
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsType.java20
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/OAuthTokenDAO.java20
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/PermDAO.java70
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/RoleDAO.java60
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/Status.java20
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/UserRoleDAO.java56
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/CassExecutor.java4
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Function.java126
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/PermLookup.java20
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Question.java164
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFLocator.java22
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFLur.java24
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFUserPass.java10
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectCertIdentity.java12
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectLocatorCreator.java10
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectRegistrar.java14
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_Cached.java20
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CachedDAO.java12
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CassAccess.java10
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CassDAOImpl.java12
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_DAOException.java20
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/AbsJUCass.java32
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_Bytification.java54
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_NsType.java10
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedCertDAOTest.java4
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedCredDAOTest.java4
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedNSDAOTest.java4
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedPermDAOTest.java32
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedRoleDAO.java42
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedUserRoleDAO.java46
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_ApprovalDAO.java66
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_ArtiDAO.java68
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_CacheInfoDAO.java94
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_CertDAOTest.java88
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_ConfigDAOTest.java68
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_DelegateDAO.java42
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_FutureDAO.java78
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_HistoryDAO.java90
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_LocateDAO.java88
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_Namespace.java18
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_NsDAO.java134
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_OAuthTokenDAO.java64
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_PermDAO.java134
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_RoleDAO.java138
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_UserRoleDAO.java100
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/hl/JU_CassExecutor.java44
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/hl/JU_Function.java686
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/hl/JU_PermLookup.java154
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFLocator.java38
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFLur.java70
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFUserPass.java80
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectCertIdentity.java14
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectLocatorCreator.java14
-rw-r--r--auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectRegistrar.java10
89 files changed, 2161 insertions, 2163 deletions
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/AbsCassDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/AbsCassDAO.java
index d0e4eaab..de0efdfd 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/AbsCassDAO.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/AbsCassDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -54,14 +54,14 @@ public abstract class AbsCassDAO<TRANS extends TransStore,DATA> {
protected static final int ASSIGNMENT_COMMAS = 2;
protected static final int WHERE_ANDS = 3;
- private Cluster cluster;
+ private Cluster cluster;
/*
* From DataStax
* com.datastax.driver.core.Session
- A session holds connections to a Cassandra cluster, allowing it to be queried. Each session maintains multiple connections to the cluster nodes,
- provides policies to choose which node to use for each query (round-robin on all nodes of the cluster by default), and handles retries for
+ A session holds connections to a Cassandra cluster, allowing it to be queried. Each session maintains multiple connections to the cluster nodes,
+ provides policies to choose which node to use for each query (round-robin on all nodes of the cluster by default), and handles retries for
failed query (when it makes sense), etc...
- Session instances are thread-safe and usually a single instance is enough per application. However, a given session can only be set to one
+ Session instances are thread-safe and usually a single instance is enough per application. However, a given session can only be set to one
keyspace at a time, so one instance per keyspace is necessary.
*/
private Session session;
@@ -76,7 +76,7 @@ public abstract class AbsCassDAO<TRANS extends TransStore,DATA> {
private static final Deque<ResetRequest> resetDeque = new ConcurrentLinkedDeque<ResetRequest>();
private static boolean resetTrigger = false;
private static long nextAvailableReset = 0;
-
+
public AbsCassDAO(TRANS trans, String name, Cluster cluster, String keyspace, Class<DATA> dataClass) {
this.name = name;
this.cluster = cluster;
@@ -95,7 +95,7 @@ public abstract class AbsCassDAO<TRANS extends TransStore,DATA> {
owningDAO = aDao;
this.dataClass = dataClass;
}
-
+
// Not used since 2015
// public static void setSessionSlot(Slot slot) {
// sessionSlot = slot;
@@ -117,7 +117,7 @@ public abstract class AbsCassDAO<TRANS extends TransStore,DATA> {
/**
* Create a PSInfo and create Prepared Statement
- *
+ *
* @param trans
* @param theCQL
* @param loader
@@ -137,7 +137,7 @@ public abstract class AbsCassDAO<TRANS extends TransStore,DATA> {
} else {
crud = CRUD.read;
}
-
+
int idx = 0, count=0;
while ((idx=cql.indexOf('?',idx))>=0) {
++idx;
@@ -145,14 +145,14 @@ public abstract class AbsCassDAO<TRANS extends TransStore,DATA> {
}
size=count;
}
-
+
public synchronized void reset() {
ps = null;
}
-
+
private synchronized BoundStatement ps(TransStore trans) throws APIException, IOException {
/* From Datastax
- You should prepare only once, and cache the PreparedStatement in your application (it is thread-safe).
+ You should prepare only once, and cache the PreparedStatement in your application (it is thread-safe).
If you call prepare multiple times with the same query string, the driver will log a warning.
*/
if (ps==null) {
@@ -173,7 +173,7 @@ public abstract class AbsCassDAO<TRANS extends TransStore,DATA> {
/**
* Execute a Prepared Statement by extracting from DATA object
- *
+ *
* @param trans
* @param text
* @param data
@@ -194,7 +194,7 @@ public abstract class AbsCassDAO<TRANS extends TransStore,DATA> {
/**
* Execute a Prepared Statement on Object[] key
- *
+ *
* @param trans
* @param text
* @param objs
@@ -211,15 +211,15 @@ public abstract class AbsCassDAO<TRANS extends TransStore,DATA> {
tt.done();
}
}
-
- /*
+
+ /*
* Note:
- *
+ *
*/
/**
* Execute a Prepared Statement by extracting from DATA object
- *
+ *
* @param trans
* @param text
* @param data
@@ -231,15 +231,15 @@ public abstract class AbsCassDAO<TRANS extends TransStore,DATA> {
/*
* "execute" (and executeAsync)
* Executes the provided query.
- This method blocks until at least some result has been received from the database. However,
- for SELECT queries, it does not guarantee that the result has been received in full. But it
- does guarantee that some response has been received from the database, and in particular
+ This method blocks until at least some result has been received from the database. However,
+ for SELECT queries, it does not guarantee that the result has been received in full. But it
+ does guarantee that some response has been received from the database, and in particular
guarantee that if the request is invalid, an exception will be thrown by this method.
Parameters:
statement - the CQL query to execute (that can be any Statement).
Returns:
- the result of the query. That result will never be null but can be empty (and will
+ the result of the query. That result will never be null but can be empty (and will
be for any non SELECT query).
*/
return Result.ok(getSession(trans).execute(
@@ -254,7 +254,7 @@ public abstract class AbsCassDAO<TRANS extends TransStore,DATA> {
/**
* Execute a Prepared Statement on Object[] key
- *
+ *
* @param trans
* @param text
* @param objs
@@ -281,12 +281,12 @@ public abstract class AbsCassDAO<TRANS extends TransStore,DATA> {
*/
public Result<List<DATA>> read(TRANS trans, String text, Object[] key) {
TimeTaken tt = trans.start(text,Env.REMOTE);
-
+
ResultSet rs;
try {
rs = getSession(trans).execute(key==null?ps(trans):ps(trans).bind(key));
-/// TEST CODE for Exception
-// boolean force = true;
+/// TEST CODE for Exception
+// boolean force = true;
// if (force) {
// Map<InetSocketAddress, Throwable> misa = new HashMap<>();
// //misa.put(new InetSocketAddress(444),new Exception("no host was tried"));
@@ -301,20 +301,20 @@ public abstract class AbsCassDAO<TRANS extends TransStore,DATA> {
} finally {
tt.done();
}
-
+
return extract(loader,rs,null /*let Array be created if necessary*/,dflt);
}
-
+
public Result<List<DATA>> read(TRANS trans, String text, DATA data) {
return read(trans,text, loader.extract(data, size, crud));
}
-
+
public Object[] keyFrom(DATA data) {
return loader.extract(data, size, CRUD.delete); // Delete is key only
}
/*
- * Note: in case PSInfos are deleted, we want to remove them from list. This is not expected,
+ * Note: in case PSInfos are deleted, we want to remove them from list. This is not expected,
* but we don't want a data leak if it does. Finalize doesn't have to happen quickly
*/
@Override
@@ -339,7 +339,7 @@ public abstract class AbsCassDAO<TRANS extends TransStore,DATA> {
} else {
DATA d;
List<DATA> data = indata==null?new ArrayList<>(rows.size()):indata;
-
+
for (Row row : rows) {
try {
d = loader.load(dataClass.newInstance(),row);
@@ -353,7 +353,7 @@ public abstract class AbsCassDAO<TRANS extends TransStore,DATA> {
return Result.ok(data);
}
}
-
+
private static final String NEW_CASSANDRA_SESSION_CREATED = "New Cassandra Session Created";
private static final String NEW_CASSANDRA_CLUSTER_OBJECT_CREATED = "New Cassandra Cluster Object Created";
private static final String NEW_CASSANDRA_SESSION = "New Cassandra Session";
@@ -363,14 +363,14 @@ public abstract class AbsCassDAO<TRANS extends TransStore,DATA> {
//package on purpose
Session session;
long timestamp;
-
+
public ResetRequest(Session session) {
this.session = session;
timestamp = System.currentTimeMillis();
}
}
-
+
public static final void primePSIs(TransStore trans) throws APIException, IOException {
for (AbsCassDAO<? extends TransStore, ?>.PSInfo psi : psinfos) {
if (psi.ps==null) {
@@ -378,7 +378,7 @@ public abstract class AbsCassDAO<TRANS extends TransStore,DATA> {
}
}
}
-
+
public final Session getSession(TransStore trans) throws APIException, IOException {
// SessionFilter unused since 2015
// Try to use Trans' session, if exists
@@ -388,12 +388,12 @@ public abstract class AbsCassDAO<TRANS extends TransStore,DATA> {
// return sess;
// }
// }
-
+
// If there's an owning DAO, use it's session
- if (owningDAO!=null) {
+ if (owningDAO!=null) {
return owningDAO.getSession(trans);
}
-
+
// OK, nothing else works... get our own.
if (session==null || resetTrigger) {
Cluster tempCluster = null;
@@ -414,7 +414,7 @@ public abstract class AbsCassDAO<TRANS extends TransStore,DATA> {
}
}
}
-
+
if (reset || session == null) {
TimeTaken tt = trans.start(NEW_CASSANDRA_SESSION, Env.SUB);
try {
@@ -458,7 +458,7 @@ public abstract class AbsCassDAO<TRANS extends TransStore,DATA> {
}
return session;
}
-
+
public final boolean reportPerhapsReset(TransStore trans, Exception e) {
if (owningDAO!=null) {
return owningDAO.reportPerhapsReset(trans, e);
@@ -468,7 +468,7 @@ public abstract class AbsCassDAO<TRANS extends TransStore,DATA> {
trans.warn().printf("Session Reset called for %s by %s ",session==null?"":session,e==null?"Mgmt Command":e.getClass().getName());
resetDeque.addFirst(new ResetRequest(session));
rv = resetTrigger = true;
- }
+ }
trans.error().log(e);
return rv;
}
@@ -494,7 +494,7 @@ public abstract class AbsCassDAO<TRANS extends TransStore,DATA> {
protected void wasModified(TRANS trans, CRUD modified, DATA data, String ... override) {
}
-
+
protected interface Accept<DATA> {
public boolean ok(DATA data);
}
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Bytification.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Bytification.java
index 965ee2c2..617f7727 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Bytification.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Bytification.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CIDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CIDAO.java
index b148e87a..13bd350b 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CIDAO.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CIDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -30,7 +30,7 @@ public interface CIDAO<TRANS extends Trans> {
/**
* Touch the date field for given Table
- *
+ *
* @param trans
* @param name
* @return
@@ -39,9 +39,9 @@ public interface CIDAO<TRANS extends Trans> {
/**
* Read all Info entries, and set local Date objects
- *
+ *
* This is to support regular data checks on the Database to speed up Caching behavior
- *
+ *
*/
public abstract Result<Void> check(TRANS trans);
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Cacheable.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Cacheable.java
index 818ae148..18946829 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Cacheable.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Cacheable.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,9 +24,9 @@ package org.onap.aaf.auth.dao;
/**
* Interface to obtain Segment Integer from DAO Data
* for use in Caching mechanism
- *
+ *
* This should typically be obtained by getting the Hash of the key, then using modulus on the size of segment.
- *
+ *
* @author Jonathan
*
*/
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Cached.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Cached.java
index 5605d653..a3fe1757 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Cached.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Cached.java
@@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -40,7 +40,7 @@ import org.onap.aaf.misc.env.Trans;
public class Cached<TRANS extends Trans, DATA extends Cacheable> extends Cache<TRANS,DATA> {
// Java does not allow creation of Arrays with Generics in them...
protected final CIDAO<TRANS> info;
-
+
private static Timer infoTimer;
private Object cache[];
public final int segSize;
@@ -73,7 +73,7 @@ public class Cached<TRANS extends Trans, DATA extends Cacheable> extends Cache<T
}
return h%segSize;
}
-
+
public void add(String key, List<DATA> data) {
@SuppressWarnings("unchecked")
Map<String,Dated> map = ((Map<String,Dated>)cache[cacheIdx(key)]);
@@ -105,21 +105,21 @@ public class Cached<TRANS extends Trans, DATA extends Cacheable> extends Cache<T
public interface Getter<D> {
public abstract Result<List<D>> get();
};
-
+
// TODO utilize Segmented Caches, and fold "get" into "reads"
@SuppressWarnings("unchecked")
public Result<List<DATA>> get(TRANS trans, String key, Getter<DATA> getter) {
List<DATA> ld = null;
Result<List<DATA>> rld = null;
-
+
int cacheIdx = cacheIdx(key);
Map<String, Dated> map = ((Map<String,Dated>)cache[cacheIdx]);
-
+
// Check for saved element in cache
Dated cached = map.get(key);
// Note: These Segment Timestamps are kept up to date with DB
Date dbStamp = info.get(trans, name,cacheIdx);
-
+
// Check for cache Entry and whether it is still good (a good Cache Entry is same or after DBEntry, so we use "before" syntax)
if (cached!=null && dbStamp!=null && dbStamp.before(cached.timestamp)) {
ld = (List<DATA>)cached.data;
@@ -139,7 +139,7 @@ public class Cached<TRANS extends Trans, DATA extends Cacheable> extends Cache<T
* @param dao
*/
public static void startCleansing(AuthzEnv env, CachedDAO<?,?,?> ... dao) {
- for (CachedDAO<?,?,?> d : dao) {
+ for (CachedDAO<?,?,?> d : dao) {
for (int i=0;i<d.segSize;++i) {
startCleansing(env, d.table()+i);
}
@@ -150,11 +150,11 @@ public class Cached<TRANS extends Trans, DATA extends Cacheable> extends Cache<T
public static<T extends Trans> void startRefresh(AuthzEnv env, CIDAO<AuthzTrans> cidao) {
if (infoTimer==null) {
infoTimer = new Timer("CachedDAO Info Refresh Timer");
- int minRefresh = 10*1000*60; // 10 mins Integer.parseInt(env.getProperty(CACHE_MIN_REFRESH_INTERVAL,"2000")); // 2 second minimum refresh
+ int minRefresh = 10*1000*60; // 10 mins Integer.parseInt(env.getProperty(CACHE_MIN_REFRESH_INTERVAL,"2000")); // 2 second minimum refresh
infoTimer.schedule(new Refresh(env,cidao, minRefresh), 1000, minRefresh); // note: Refresh from DB immediately
}
}
-
+
public static void stopTimer() {
Cache.stopTimer();
if (infoTimer!=null) {
@@ -162,21 +162,21 @@ public class Cached<TRANS extends Trans, DATA extends Cacheable> extends Cache<T
infoTimer = null;
}
}
-
+
private static final class Refresh extends TimerTask {
private static final int MAXREFRESH = 2*60*10000; // 20 mins
private AuthzEnv env;
private CIDAO<AuthzTrans> cidao;
private int minRefresh;
private long lastRun;
-
+
public Refresh(AuthzEnv env, CIDAO<AuthzTrans> cidao, int minRefresh) {
this.env = env;
this.cidao = cidao;
this.minRefresh = minRefresh;
lastRun = System.currentTimeMillis()-MAXREFRESH-1000;
}
-
+
@Override
public void run() {
// Evaluate whether to refresh based on transaction rate
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CachedDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CachedDAO.java
index cf410d0b..4e2cd72a 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CachedDAO.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CachedDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -30,25 +30,25 @@ import org.onap.aaf.misc.env.Trans;
/**
* CachedDAO
- *
- * Cache the response of "get" of any DAO.
- *
- * For simplicity's sake, at this time, we only do this for single Object keys
- *
+ *
+ * Cache the response of "get" of any DAO.
+ *
+ * For simplicity's sake, at this time, we only do this for single Object keys
+ *
* @author Jonathan
*
* @param <DATA>
*/
-public class CachedDAO<TRANS extends Trans,D extends DAO<TRANS,DATA>,DATA extends Cacheable>
+public class CachedDAO<TRANS extends Trans,D extends DAO<TRANS,DATA>,DATA extends Cacheable>
extends Cached<TRANS,DATA> implements DAO_RO<TRANS,DATA>{
-// private final String dirty_str;
-
+// private final String dirty_str;
+
private final D dao;
public CachedDAO(D dao, CIDAO<TRANS> info, int segsize, long expireIn) {
super(info, dao.table(), segsize, expireIn);
-
- // Instantiate a new Cache per DAO name (so separate instances use the same cache)
+
+ // Instantiate a new Cache per DAO name (so separate instances use the same cache)
this.dao = dao;
//read_str = "Cached READ for " + dao.table();
// dirty_str = "Cache DIRTY on " + dao.table();
@@ -56,8 +56,8 @@ public class CachedDAO<TRANS extends Trans,D extends DAO<TRANS,DATA>,DATA extend
((CassDAOImpl<?,?>)dao).cache = this;
}
}
-
- public static<T extends Trans, DA extends DAO<T,DT>, DT extends Cacheable>
+
+ public static<T extends Trans, DA extends DAO<T,DT>, DT extends Cacheable>
CachedDAO<T,DA,DT> create(DA dao, CIDAO<T> info, int segsize, long expireIn) {
return new CachedDAO<T,DA,DT>(dao,info, segsize, expireIn);
}
@@ -68,7 +68,7 @@ public class CachedDAO<TRANS extends Trans,D extends DAO<TRANS,DATA>,DATA extend
list.add(data);
super.add(key,list);
}
-
+
// public void invalidate(TRANS trans, Object ... objs) {
// TimeTaken tt = trans.start(dirty_str, Env.SUB);
// try {
@@ -122,7 +122,7 @@ public class CachedDAO<TRANS extends Trans,D extends DAO<TRANS,DATA>,DATA extend
this.dao = dao;
this.objs = objs;
}
-
+
/**
* Separated into single call for easy overloading
* @return
@@ -130,7 +130,7 @@ public class CachedDAO<TRANS extends Trans,D extends DAO<TRANS,DATA>,DATA extend
public Result<List<DATA>> call() {
return dao.read(trans, objs);
}
-
+
@Override
public final Result<List<DATA>> get() {
return call();
@@ -144,7 +144,7 @@ public class CachedDAO<TRANS extends Trans,D extends DAO<TRANS,DATA>,DATA extend
@Override
public Result<List<DATA>> read(final TRANS trans, final Object ... objs) {
- DAOGetter getter = new DAOGetter(trans,dao,objs);
+ DAOGetter getter = new DAOGetter(trans,dao,objs);
return get(trans, keyFromObjs(objs),getter);
// if (ld!=null) {
// return Result.ok(ld);//.emptyList(ld.isEmpty());
@@ -156,9 +156,9 @@ public class CachedDAO<TRANS extends Trans,D extends DAO<TRANS,DATA>,DATA extend
// return getter.result;
}
- // Slight Improved performance available when String and Obj versions are known.
+ // Slight Improved performance available when String and Obj versions are known.
public Result<List<DATA>> read(final String key, final TRANS trans, final Object[] objs) {
- DAOGetter getter = new DAOGetter(trans,dao,objs);
+ DAOGetter getter = new DAOGetter(trans,dao,objs);
return get(trans, key, getter);
// if (ld!=null) {
// return Result.ok(ld);//.emptyList(ld.isEmpty());
@@ -169,7 +169,7 @@ public class CachedDAO<TRANS extends Trans,D extends DAO<TRANS,DATA>,DATA extend
// }
// return getter.result;
}
-
+
@Override
public Result<List<DATA>> read(TRANS trans, DATA data) {
return read(trans,dao.keyFrom(data));
@@ -202,24 +202,24 @@ public class CachedDAO<TRANS extends Trans,D extends DAO<TRANS,DATA>,DATA extend
data.invalidate(this);
return rv;
}
-
+
@Override
public void close(TRANS trans) {
if (dao!=null) {
dao.close(trans);
}
}
-
+
@Override
public String table() {
return dao.table();
}
-
+
public D dao() {
return dao;
}
-
+
public void invalidate(TRANS trans, DATA data) {
if (info.touch(trans, dao.table(),data.invalidate(this)).notOK()) {
trans.error().log("Cannot touch CacheInfo for Role");
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassAccess.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassAccess.java
index c5ad4599..4246d314 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassAccess.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassAccess.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -93,7 +93,7 @@ public class CassAccess {
cb.withCredentials(str, env.decryptor().decrypt(epass));
}
}
-
+
str = env.getProperty(pre+CASSANDRA_RESET_EXCEPTIONS,env.getProperty(CASSANDRA_RESET_EXCEPTIONS,null));
if (str!=null) {
env.init().log("Cass ResetExceptions = ",str );
@@ -101,7 +101,7 @@ public class CassAccess {
resetExceptions.add(new Resettable(env,ex));
}
}
-
+
str = env.getProperty(Config.CADI_LATITUDE);
Double lat = str!=null && !str.isEmpty()?Double.parseDouble(str):null;
str = env.getProperty(Config.CADI_LONGITUDE);
@@ -109,9 +109,9 @@ public class CassAccess {
if (lat == null || lon == null) {
throw new APIException(Config.CADI_LATITUDE + " and/or " + Config.CADI_LONGITUDE + " are not set");
}
-
+
env.init().printf("Service Latitude,Longitude = %f,%f",lat,lon);
-
+
str = env.getProperty(pre+CASSANDRA_CLUSTERS,env.getProperty(CASSANDRA_CLUSTERS,"localhost"));
env.init().printf("Cass Clusters = '%s'\n",str );
String[] machs = Split.split(',', str);
@@ -124,7 +124,7 @@ public class CassAccess {
if (minfo.length>0) {
cpoints[i]=minfo[0];
}
-
+
if (minfo.length>3) {
if (minfo[1].equals(bestDC)) {
++numInBestDC;
@@ -143,9 +143,9 @@ public class CassAccess {
}
}
}
-
+
cb.addContactPoints(cpoints);
-
+
if (bestDC!=null) {
// 8/26/2016 Management has determined that Accuracy is preferred over speed in bad situations
// Local DC Aware Load Balancing appears to have the highest normal performance, with the best
@@ -166,11 +166,11 @@ public class CassAccess {
cb.withSocketOptions(new SocketOptions().setReadTimeoutMillis(6500000));
return cb.build();
}
-
+
private static class Resettable {
private Class<? extends Exception> cls;
private List<String> messages;
-
+
@SuppressWarnings("unchecked")
public Resettable(Env env, String propData) throws APIException {
if (propData!=null && propData.length()>1) {
@@ -195,7 +195,7 @@ public class CassAccess {
}
}
}
-
+
public boolean matches(Exception ex) {
if (ex.getClass().equals(cls)) {
if (messages!=null) {
@@ -210,7 +210,7 @@ public class CassAccess {
return false;
}
}
-
+
public static final boolean isResetException(Exception e) {
if (e==null) {
return true;
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassDAOImpl.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassDAOImpl.java
index 68ec2e8b..bb4e2103 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassDAOImpl.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassDAOImpl.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -62,7 +62,7 @@ public class CassDAOImpl<TRANS extends TransStore,DATA> extends AbsCassDAO<TRANS
protected final String U_TEXT = getClass().getSimpleName() + " UPDATE";
protected final String D_TEXT = getClass().getSimpleName() + " DELETE";
private String table;
-
+
protected final ConsistencyLevel readConsistency;
protected final ConsistencyLevel writeConsistency;
@@ -71,7 +71,7 @@ public class CassDAOImpl<TRANS extends TransStore,DATA> extends AbsCassDAO<TRANS
protected PSInfo updatePS;
protected PSInfo deletePS;
protected boolean async=false;
-
+
// Setteable only by CachedDAO
protected Cached<?, ?> cache;
@@ -89,7 +89,7 @@ public class CassDAOImpl<TRANS extends TransStore,DATA> extends AbsCassDAO<TRANS
readConsistency = read;
writeConsistency = write;
}
-
+
/**
* A Constructor to share Session with other DAOs.
*
@@ -113,18 +113,18 @@ public class CassDAOImpl<TRANS extends TransStore,DATA> extends AbsCassDAO<TRANS
public final String[] setCRUD(TRANS trans, String table, Class<?> dc,Loader<DATA> loader) {
return setCRUD(trans, table, dc, loader, -1);
}
-
+
public final String[] setCRUD(TRANS trans, String table, Class<?> dc,Loader<DATA> loader, int max) {
Field[] fields = dc.getDeclaredFields();
int end = max>=0 && max<fields.length?max:fields.length;
// get keylimit from a non-null Loader
int keylimit = loader.keylimit();
-
+
StringBuilder sbfc = new StringBuilder();
StringBuilder sbq = new StringBuilder();
StringBuilder sbwc = new StringBuilder();
StringBuilder sbup = new StringBuilder();
-
+
if (keylimit>0) {
for (int i=0;i<end;++i) {
if (i>0) {
@@ -148,18 +148,18 @@ public class CassDAOImpl<TRANS extends TransStore,DATA> extends AbsCassDAO<TRANS
sbwc.append("=?");
}
}
-
+
createPS = new PSInfo(trans, "INSERT INTO " + table + " ("+ sbfc +") VALUES ("+ sbq +");",loader,writeConsistency);
-
+
readPS = new PSInfo(trans, SELECT_SP + sbfc + " FROM " + table + WHERE + sbwc + ';',loader,readConsistency);
-
+
// Note: UPDATES can't compile if there are no fields besides keys... Use "Insert"
if (sbup.length()==0) {
updatePS = createPS; // the same as an insert
} else {
updatePS = new PSInfo(trans, UPDATE_SP + table + " SET " + sbup + WHERE + sbwc + ';',loader,writeConsistency);
}
-
+
deletePS = new PSInfo(trans, "DELETE FROM " + table + WHERE + sbwc + ';',loader,writeConsistency);
}
return new String[] {sbfc.toString(), sbq.toString(), sbup.toString(), sbwc.toString()};
@@ -191,7 +191,7 @@ public class CassDAOImpl<TRANS extends TransStore,DATA> extends AbsCassDAO<TRANS
}
}
-
+
/**
* Given a DATA object, extract the individual elements from the Data into an Object Array for the
* execute element.
@@ -231,7 +231,7 @@ public class CassDAOImpl<TRANS extends TransStore,DATA> extends AbsCassDAO<TRANS
}
return readPS.read(trans, R_TEXT, key);
}
-
+
public Result<DATA> readPrimKey(TRANS trans, Object ... key) {
if (readPS==null) {
return Result.err(Result.ERR_NotImplemented,READ_IS_DISABLED,getClass().getSimpleName());
@@ -267,7 +267,7 @@ public class CassDAOImpl<TRANS extends TransStore,DATA> extends AbsCassDAO<TRANS
return Result.err(rs);
}
}
-
+
wasModified(trans, CRUD.update, data);
return Result.ok();
}
@@ -286,7 +286,7 @@ public class CassDAOImpl<TRANS extends TransStore,DATA> extends AbsCassDAO<TRANS
if (rd.isEmpty()) {
return Result.err(Status.ERR_NotFound,"Not Found");
}
- for (DATA d : rd.value) {
+ for (DATA d : rd.value) {
if (async) {
Result<ResultSetFuture> rs = deletePS.execAsync(trans, D_TEXT, d);
if (rs.notOK()) {
@@ -316,7 +316,7 @@ public class CassDAOImpl<TRANS extends TransStore,DATA> extends AbsCassDAO<TRANS
}
return Result.ok();
}
-
+
public final Object[] keyFrom(DATA data) {
return createPS.keyFrom(data);
}
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/DAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/DAO.java
index 38759075..8d9185ba 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/DAO.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/DAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/DAOException.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/DAOException.java
index 7871e875..5045f6ec 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/DAOException.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/DAOException.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,7 +25,7 @@ package org.onap.aaf.auth.dao;
public class DAOException extends Exception {
/**
- *
+ *
*/
private static final long serialVersionUID = 1527904125585539823L;
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/DAO_RO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/DAO_RO.java
index ca4277e1..b8f3448c 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/DAO_RO.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/DAO_RO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,11 +28,11 @@ import org.onap.aaf.misc.env.Trans;
/**
* DataAccessObject - ReadOnly
- *
+ *
* It is useful to have a ReadOnly part of the interface for CachedDAO
- *
+ *
* Normal DAOs will implement full DAO
- *
+ *
* @author Jonathan
*
* @param <DATA>
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Loader.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Loader.java
index 4a078f90..93203810 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Loader.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Loader.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -40,11 +40,11 @@ public abstract class Loader<DATA> {
public Loader(int keylimit) {
this.keylimit = keylimit;
}
-
+
public int keylimit() {
return keylimit;
}
-
+
protected abstract DATA load(DATA data, Row row);
protected abstract void key(DATA data, int idx, Object[] obj);
protected abstract void body(DATA data, int idx, Object[] obj);
@@ -74,7 +74,7 @@ public abstract class Loader<DATA> {
}
return rv;
}
-
+
public static void writeString(DataOutputStream os, String s) throws IOException {
if (s==null) {
os.writeInt(-1);
@@ -90,11 +90,11 @@ public abstract class Loader<DATA> {
}
}
}
-
-
+
+
/**
* We use bytes here to set a Maximum
- *
+ *
* @param is
* @param MAX
* @return
@@ -118,10 +118,10 @@ public abstract class Loader<DATA> {
/**
* Write a set with proper sizing
- *
+ *
* Note: at the moment, this is just String. Probably can develop system where types
* are supported too... but not now.
- *
+ *
* @param os
* @param set
* @throws IOException
@@ -137,7 +137,7 @@ public abstract class Loader<DATA> {
}
}
-
+
public static Set<String> readStringSet(DataInputStream is, byte[] buff) throws IOException {
int l = is.readInt();
if (l<0) {
@@ -149,7 +149,7 @@ public abstract class Loader<DATA> {
}
return set;
}
-
+
public static List<String> readStringList(DataInputStream is, byte[] buff) throws IOException {
int l = is.readInt();
if (l<0) {
@@ -162,7 +162,7 @@ public abstract class Loader<DATA> {
return list;
}
- /**
+ /**
* Write a map
* @param os
* @param map
@@ -198,7 +198,7 @@ public abstract class Loader<DATA> {
os.writeInt(magic);
os.writeInt(version);
}
-
+
public static int readHeader(DataInputStream is, final int magic, final int version) throws IOException {
if (is.readInt()!=magic) {
throw new IOException("Corrupted Data Stream");
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Streamer.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Streamer.java
index af3567eb..a072289f 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Streamer.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Streamer.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Touchable.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Touchable.java
index 0fcda19c..2707f7a0 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Touchable.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Touchable.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedCertDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedCertDAO.java
index c0a2c49c..9b86f80c 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedCertDAO.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedCertDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -33,19 +33,19 @@ public class CachedCertDAO extends CachedDAO<AuthzTrans, CertDAO, CertDAO.Data>
public CachedCertDAO(CertDAO dao, CIDAO<AuthzTrans> info, long expiresIn) {
super(dao, info, CertDAO.CACHE_SEG, expiresIn);
}
-
+
/**
* Pass through Cert ID Lookup
- *
+ *
* @param trans
* @param ns
* @return
*/
-
+
public Result<List<CertDAO.Data>> readID(AuthzTrans trans, final String id) {
return dao().readID(trans, id);
}
-
+
public Result<List<CertDAO.Data>> readX500(AuthzTrans trans, final String x500) {
return dao().readX500(trans, x500);
}
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedCredDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedCredDAO.java
index a8a3796a..9c55d464 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedCredDAO.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedCredDAO.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -35,7 +35,7 @@ import org.onap.aaf.auth.layer.Result;
public class CachedCredDAO extends CachedDAO<AuthzTrans, CredDAO, CredDAO.Data> {
private final ReadID readID;
private final ReadID readIDBath;
-
+
public CachedCredDAO(CredDAO dao, CIDAO<AuthzTrans> info, long expiresIn) {
super(dao, info, CredDAO.CACHE_SEG, expiresIn);
if(FileGetter.isLoaded) {
@@ -52,12 +52,12 @@ public class CachedCredDAO extends CachedDAO<AuthzTrans, CredDAO, CredDAO.Data>
@Override
public Result<List<Data>> read(AuthzTrans trans, final String id) {
DAOGetter getter = new DAOGetter(trans,dao()) {
- @Override
+ @Override
public Result<List<CredDAO.Data>> call() {
return dao().readID(trans, id);
}
};
-
+
Result<List<CredDAO.Data>> lurd = get(trans, id, getter);
if (lurd.isOK() && lurd.isEmpty()) {
return Result.err(Status.ERR_UserNotFound,"No User Cred found");
@@ -65,17 +65,17 @@ public class CachedCredDAO extends CachedDAO<AuthzTrans, CredDAO, CredDAO.Data>
return lurd;
}
};
-
+
readIDBath = new ReadID() {
@Override
public Result<List<Data>> read(AuthzTrans trans, final String id) {
DAOGetter getter = new DAOGetter(trans,dao()) {
- @Override
+ @Override
public Result<List<CredDAO.Data>> call() {
return dao().readIDBAth(trans, id);
}
};
-
+
Result<List<CredDAO.Data>> lurd = get(trans, id, getter);
if (lurd.isOK() && lurd.isEmpty()) {
return Result.err(Status.ERR_UserNotFound,"No User Cred found");
@@ -85,18 +85,18 @@ public class CachedCredDAO extends CachedDAO<AuthzTrans, CredDAO, CredDAO.Data>
};
}
}
-
+
/**
* Pass through Cred Lookup
- *
+ *
* Unlike Role and Perm, we don't need or want to cache these elements... Only used for NS Delete.
- *
+ *
* @param trans
* @param ns
* @return
*/
public Result<List<CredDAO.Data>> readNS(AuthzTrans trans, final String ns) {
-
+
return dao().readNS(trans, ns);
}
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedNSDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedNSDAO.java
index e639767c..df089d00 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedNSDAO.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedNSDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedPermDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedPermDAO.java
index 13180ab1..7ea7dd75 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedPermDAO.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedPermDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -44,12 +44,12 @@ public class CachedPermDAO extends CachedDAO<AuthzTrans,PermDAO, PermDAO.Data> {
return dao.readNS(trans, ns);
}
};
-
+
Result<List<Data>> lurd = get(trans, ns, getter);
if (lurd.isOKhasData()) {
return lurd;
} else {
-
+
}
// if (getter.result==null) {
// if (lurd==null) {
@@ -66,7 +66,7 @@ public class CachedPermDAO extends CachedDAO<AuthzTrans,PermDAO, PermDAO.Data> {
}
/**
- *
+ *
* @param trans
* @param ns
* @param type
@@ -78,7 +78,7 @@ public class CachedPermDAO extends CachedDAO<AuthzTrans,PermDAO, PermDAO.Data> {
return dao.readByType(trans, ns, type);
}
};
-
+
// Note: Can reuse index1 here, because there is no name collision versus response
Result<List<Data>> lurd = get(trans, ns+'|'+type, getter);
if (lurd.isOK() && lurd.isEmpty()) {
@@ -86,10 +86,10 @@ public class CachedPermDAO extends CachedDAO<AuthzTrans,PermDAO, PermDAO.Data> {
}
return lurd;
}
-
+
/**
* Add desciption to this permission
- *
+ *
* @param trans
* @param ns
* @param type
@@ -98,12 +98,12 @@ public class CachedPermDAO extends CachedDAO<AuthzTrans,PermDAO, PermDAO.Data> {
* @param description
* @return
*/
- public Result<Void> addDescription(AuthzTrans trans, String ns, String type,
+ public Result<Void> addDescription(AuthzTrans trans, String ns, String type,
String instance, String action, String description) {
//TODO Invalidate?
return dao().addDescription(trans, ns, type, instance, action, description);
}
-
+
public Result<Void> addRole(AuthzTrans trans, PermDAO.Data perm, RoleDAO.Data role) {
Result<Void> rv = dao().addRole(trans,perm,role.encode());
if (trans.debug().isLoggable())
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedRoleDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedRoleDAO.java
index 99fac2da..b90c3579 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedRoleDAO.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedRoleDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -43,7 +43,7 @@ public class CachedRoleDAO extends CachedDAO<AuthzTrans,RoleDAO, RoleDAO.Data> {
return dao.readNS(trans, ns);
}
};
-
+
Result<List<Data>> lurd = get(trans, ns, getter);
if (lurd.isOK() && lurd.isEmpty()) {
return Result.err(Status.ERR_RoleNotFound,"No Role found");
@@ -57,7 +57,7 @@ public class CachedRoleDAO extends CachedDAO<AuthzTrans,RoleDAO, RoleDAO.Data> {
return dao().readName(trans, name);
}
};
-
+
Result<List<Data>> lurd = get(trans, name, getter);
if (lurd.isOK() && lurd.isEmpty()) {
return Result.err(Status.ERR_RoleNotFound,"No Role found");
@@ -87,10 +87,10 @@ public class CachedRoleDAO extends CachedDAO<AuthzTrans,RoleDAO, RoleDAO.Data> {
invalidate(trans, rd);
return rv;
}
-
+
/**
* Add description to this role
- *
+ *
* @param trans
* @param ns
* @param name
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedUserRoleDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedUserRoleDAO.java
index c1aa9017..c3f353e0 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedUserRoleDAO.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedUserRoleDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -42,7 +42,7 @@ public class CachedUserRoleDAO extends CachedDAO<AuthzTrans,UserRoleDAO, UserRol
}
/**
- * Special Case.
+ * Special Case.
* User Roles by User are very likely to be called many times in a Transaction, to validate "May User do..."
* Pull result, and make accessible by the Trans, which is always keyed by User.
* @param trans
@@ -71,7 +71,7 @@ public class CachedUserRoleDAO extends CachedDAO<AuthzTrans,UserRoleDAO, UserRol
return lurd;
}
-
+
public Result<List<Data>> readByRole(AuthzTrans trans, final String role) {
DAOGetter getter = new DAOGetter(trans,dao()) {
public Result<List<Data>> call() {
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/FileGetter.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/FileGetter.java
index a8c86fa5..702f989a 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/FileGetter.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/FileGetter.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -42,107 +42,105 @@ import org.onap.aaf.cadi.PropAccess;
import org.onap.aaf.cadi.util.CSV;
public class FileGetter {
- private static final String AAF_FILEGETTER = "aaf_filegetter";
- public static boolean isLoaded = false;
- private static FileGetter singleton;
+ private static final String AAF_FILEGETTER = "aaf_filegetter";
+ public static boolean isLoaded = false;
+ private static FileGetter singleton;
+
+ private Map<String,List<CredDAO.Data>> data;
+ private SimpleDateFormat sdf;
+ private FileGetter(Access access) {
+ if(access!=null) {
+ String filename = access.getProperty(AAF_FILEGETTER,null);
+ if((filename!=null)&&(!isLoaded)) {
+ data = new TreeMap<>();
+ sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss+SSSS");
+ CSV csv = new CSV(access, filename).setDelimiter('|');
+ try {
+ access.log(Level.INIT, "Loading Filebased Cred from",filename);
+ csv.visit(row -> {
+ if(row.size()<1) {
+ access.log(Level.INIT, "Bad Row");
+ }
+ int type;
+ try {
+ type =Integer.parseInt(row.get(1));
+ } catch(Exception e) {
+ access.log(Level.INIT, e, "skipping ", row.get(0));
+ return;
+ }
+ if(CredDAO.CERT_SHA256_RSA == type) {
+ return;
+ }
+ CredDAO.Data cdd = new CredDAO.Data();
+ cdd.id=row.get(0);
+ cdd.type = type;
+ try {
+ cdd.expires = sdf.parse(row.get(2));
+ cdd.cred = ByteBuffer.wrap(Hash.fromHex(row.get(3)));
+ cdd.notes= row.get(4);
+ cdd.ns = row.get(5);
+ cdd.other = Integer.parseInt(row.get(6));
+ if(row.size()>8) {
+ cdd.tag = row.get(8);
+ } else {
+ cdd.tag = "";
+ }
+ List<CredDAO.Data> lcdd = data.get(cdd.id);
+ if(lcdd == null) {
+ lcdd = new ArrayList<>();
+ data.put(cdd.id, lcdd);
+ }
+ lcdd.add(cdd);
+ } catch (ParseException e) {
+ access.log(Level.INIT, e);
+ }
+
+ });
+ access.printf(Level.INIT, "Filebased Cred finished...");
+ isLoaded = true;
+ } catch( CadiException | IOException e) {
+ access.log(Level.ERROR, e);
+ }
+ }
+ }
+ }
+
+ public static synchronized FileGetter singleton(Access access) {
+ if(singleton==null) {
+ singleton = new FileGetter(access);
+ }
+ return singleton;
+
+ }
+ public Getter<CredDAO.Data> getter(String id) {
+ return new FGetter(id);
+ }
+ private static List<CredDAO.Data> EMPTY = new ArrayList<>();
+ public class FGetter implements Getter<CredDAO.Data> {
+ private final List<CredDAO.Data> lcdd;
+ public FGetter(final String id) {
+ lcdd = data.get(id);
+ }
+ @Override
+ public Result<List<Data>> get() {
+ return Result.ok(lcdd==null?EMPTY:lcdd);
+ }
+ }
- private Map<String,List<CredDAO.Data>> data;
- private SimpleDateFormat sdf;
- private FileGetter(Access access) {
- if(access!=null) {
- String filename = access.getProperty(AAF_FILEGETTER,null);
- if((filename!=null)&&(!isLoaded)) {
- data = new TreeMap<>();
- sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss+SSSS");
- CSV csv = new CSV(access, filename).setDelimiter('|');
- try {
- access.log(Level.INIT, "Loading Filebased Cred from",filename);
- csv.visit(row -> {
- if(row.size()<1) {
- access.log(Level.INIT, "Bad Row");
- }
- int type;
- try {
- type =Integer.parseInt(row.get(1));
- } catch(Exception e) {
- access.log(Level.INIT, e, "skipping ", row.get(0));
- return;
- }
- if(CredDAO.CERT_SHA256_RSA == type) {
- return;
- }
- CredDAO.Data cdd = new CredDAO.Data();
- cdd.id=row.get(0);
- cdd.type = type;
- try {
- cdd.expires = sdf.parse(row.get(2));
- cdd.cred = ByteBuffer.wrap(Hash.fromHex(row.get(3)));
- cdd.notes= row.get(4);
- cdd.ns = row.get(5);
- cdd.other = Integer.parseInt(row.get(6));
- if(row.size()>8) {
- cdd.tag = row.get(8);
- } else {
- cdd.tag = "";
- }
- List<CredDAO.Data> lcdd = data.get(cdd.id);
- if(lcdd == null) {
- lcdd = new ArrayList<>();
- data.put(cdd.id, lcdd);
- }
- lcdd.add(cdd);
-
- } catch (ParseException e) {
- access.log(Level.INIT, e);
- }
-
- });
- access.printf(Level.INIT, "Filebased Cred finished...");
- isLoaded = true;
- } catch( CadiException | IOException e) {
- access.log(Level.ERROR, e);
- }
-
- }
- }
- }
+ public static void main(String[] args) {
+ PropAccess access = new PropAccess(args);
+ access.setProperty(AAF_FILEGETTER,"/Users/jg1555/cred.dat");
+ FileGetter fg = FileGetter.singleton(access);
- public static synchronized FileGetter singleton(Access access) {
- if(singleton==null) {
- singleton = new FileGetter(access);
- }
- return singleton;
-
- }
- public Getter<CredDAO.Data> getter(String id) {
- return new FGetter(id);
- }
- private static List<CredDAO.Data> EMPTY = new ArrayList<>();
- public class FGetter implements Getter<CredDAO.Data> {
- private final List<CredDAO.Data> lcdd;
- public FGetter(final String id) {
- lcdd = data.get(id);
- }
- @Override
- public Result<List<Data>> get() {
- return Result.ok(lcdd==null?EMPTY:lcdd);
- }
- }
-
- public static void main(String[] args) {
- PropAccess access = new PropAccess(args);
- access.setProperty(AAF_FILEGETTER,"/Users/jg1555/cred.dat");
- FileGetter fg = FileGetter.singleton(access);
-
- for(String id : new String[] {"m01891@aaf.att.com","bogus"}) {
- Getter<CredDAO.Data> g = fg.getter(id);
- Result<List<CredDAO.Data>> r = g.get();
- if(r.isOKhasData()) {
- for(CredDAO.Data cdd : r.value) {
- System.out.println(cdd);
- }
- }
- }
- }
+ for(String id : new String[] {"m01891@aaf.att.com","bogus"}) {
+ Getter<CredDAO.Data> g = fg.getter(id);
+ Result<List<CredDAO.Data>> r = g.get();
+ if(r.isOKhasData()) {
+ for(CredDAO.Data cdd : r.value) {
+ System.out.println(cdd);
+ }
+ }
+ }
+ }
}
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ApprovalDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ApprovalDAO.java
index 5583dc03..139e85a9 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ApprovalDAO.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ApprovalDAO.java
@@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -48,7 +48,7 @@ public class ApprovalDAO extends CassDAOImpl<AuthzTrans,ApprovalDAO.Data> {
public static final String PENDING = "pending";
public static final String DENIED = "denied";
public static final String APPROVED = "approved";
-
+
private static final String TABLE = "approval";
private static final String TABLELOG = "approved";
private HistoryDAO historyDAO;
@@ -58,7 +58,7 @@ public class ApprovalDAO extends CassDAOImpl<AuthzTrans,ApprovalDAO.Data> {
private PSInfo psByStatus;
private static final int KEYLIMIT = 1;
-
+
public ApprovalDAO(AuthzTrans trans, Cluster cluster, String keyspace) {
super(trans, ApprovalDAO.class.getSimpleName(),cluster,keyspace,Data.class,TABLE, readConsistency(trans,TABLE), writeConsistency(trans,TABLE));
historyDAO = new HistoryDAO(trans, this);
@@ -83,14 +83,14 @@ public class ApprovalDAO extends CassDAOImpl<AuthzTrans,ApprovalDAO.Data> {
public String operation;
public Date updated;
}
-
+
private static class ApprovalLoader extends Loader<Data> {
public static final ApprovalLoader deflt = new ApprovalLoader(KEYLIMIT);
-
+
public ApprovalLoader(int keylimit) {
super(keylimit);
}
-
+
@Override
public Data load(Data data, Row row) {
data.id = row.getUUID(0);
@@ -101,7 +101,7 @@ public class ApprovalDAO extends CassDAOImpl<AuthzTrans,ApprovalDAO.Data> {
data.status = row.getString(5);
data.memo = row.getString(6);
data.operation = row.getString(7);
- // This is used to get "WRITETIME(STATUS)" from Approval, which gives us an "updated"
+ // This is used to get "WRITETIME(STATUS)" from Approval, which gives us an "updated"
if (row.getColumnDefinitions().size()>8) {
// Rows reported in MicroSeconds
data.updated = new Date(row.getLong(8)/1000);
@@ -125,19 +125,19 @@ public class ApprovalDAO extends CassDAOImpl<AuthzTrans,ApprovalDAO.Data> {
obj[++idx]=data.memo;
obj[++idx]=data.operation;
}
- }
-
+ }
+
private void init(AuthzTrans trans) {
String[] helpers = setCRUD(trans, TABLE, Data.class, ApprovalLoader.deflt,8);
- psByUser = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + ", WRITETIME(status) FROM " + TABLE +
+ psByUser = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + ", WRITETIME(status) FROM " + TABLE +
" WHERE user = ?", new ApprovalLoader(1) {
@Override
protected void key(Data data, int idx, Object[] obj) {
obj[idx]=data.user;
}
}, readConsistency);
-
- psByApprover = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + ", WRITETIME(status) FROM " + TABLE +
+
+ psByApprover = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + ", WRITETIME(status) FROM " + TABLE +
" WHERE approver = ?", new ApprovalLoader(1) {
@Override
protected void key(Data data, int idx, Object[] obj) {
@@ -145,7 +145,7 @@ public class ApprovalDAO extends CassDAOImpl<AuthzTrans,ApprovalDAO.Data> {
}
}, readConsistency);
- psByTicket = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + ", WRITETIME(status) FROM " + TABLE +
+ psByTicket = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + ", WRITETIME(status) FROM " + TABLE +
" WHERE ticket = ?", new ApprovalLoader(1) {
@Override
protected void key(Data data, int idx, Object[] obj) {
@@ -153,7 +153,7 @@ public class ApprovalDAO extends CassDAOImpl<AuthzTrans,ApprovalDAO.Data> {
}
}, readConsistency);
- psByStatus = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + ", WRITETIME(status) FROM " + TABLE +
+ psByStatus = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + ", WRITETIME(status) FROM " + TABLE +
" WHERE status = ?", new ApprovalLoader(1) {
@Override
protected void key(Data data, int idx, Object[] obj) {
@@ -177,7 +177,7 @@ public class ApprovalDAO extends CassDAOImpl<AuthzTrans,ApprovalDAO.Data> {
if (rs.notOK()) {
return Result.err(rs);
}
- return Result.ok(data);
+ return Result.ok(data);
}
@@ -195,7 +195,7 @@ public class ApprovalDAO extends CassDAOImpl<AuthzTrans,ApprovalDAO.Data> {
public Result<List<ApprovalDAO.Data>> readByStatus(AuthzTrans trans, String status) {
return psByStatus.read(trans, R_TEXT, new Object[]{status});
- }
+ }
/* (non-Javadoc)
* @see org.onap.aaf.auth.dao.CassDAOImpl#delete(com.att.inno.env.TransStore, java.lang.Object, boolean)
@@ -209,7 +209,7 @@ public class ApprovalDAO extends CassDAOImpl<AuthzTrans,ApprovalDAO.Data> {
}
ApprovalLoader.deflt.load(data, rd.value.one());
}
- if (APPROVED.equals(data.status) || DENIED.equals(data.status)) {
+ if (APPROVED.equals(data.status) || DENIED.equals(data.status)) {
StringBuilder sb = new StringBuilder("BEGIN BATCH\n");
sb.append("INSERT INTO ");
sb.append(TABLELOG);
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ArtiDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ArtiDAO.java
index e0c0c0d4..08de28ec 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ArtiDAO.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ArtiDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -43,16 +43,16 @@ import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Row;
/**
- * CredDAO manages credentials.
+ * CredDAO manages credentials.
* @author Jonathan
* Date: 7/19/13
*/
public class ArtiDAO extends CassDAOImpl<AuthzTrans,ArtiDAO.Data> {
public static final String TABLE = "artifact";
-
+
private HistoryDAO historyDAO;
private PSInfo psByMechID,psByMachine, psByNs;
-
+
public ArtiDAO(AuthzTrans trans, Cluster cluster, String keyspace) {
super(trans, ArtiDAO.class.getSimpleName(),cluster, keyspace, Data.class,TABLE, readConsistency(trans,TABLE), writeConsistency(trans,TABLE));
init(trans);
@@ -78,7 +78,7 @@ public class ArtiDAO extends CassDAOImpl<AuthzTrans,ArtiDAO.Data> {
public Date expires;
public int renewDays;
public Set<String> sans;
-
+
// // Getters
public Set<String> type(boolean mutable) {
if (type == null) {
@@ -104,7 +104,7 @@ public class ArtiDAO extends CassDAOImpl<AuthzTrans,ArtiDAO.Data> {
ArtifactLoader.deflt.marshal(this,new DataOutputStream(baos));
return ByteBuffer.wrap(baos.toByteArray());
}
-
+
@Override
public void reconstitute(ByteBuffer bb) throws IOException {
ArtifactLoader.deflt.unmarshal(this, toDIS(bb));
@@ -118,7 +118,7 @@ public class ArtiDAO extends CassDAOImpl<AuthzTrans,ArtiDAO.Data> {
private static class ArtifactLoader extends Loader<Data> implements Streamer<Data>{
public static final int MAGIC=95829343;
public static final int VERSION=1;
- public static final int BUFF_SIZE=48; // Note:
+ public static final int BUFF_SIZE=48; // Note:
public static final ArtifactLoader deflt = new ArtifactLoader(KEYLIMIT);
public ArtifactLoader(int keylimit) {
@@ -225,10 +225,10 @@ public class ArtiDAO extends CassDAOImpl<AuthzTrans,ArtiDAO.Data> {
if (historyDAO==null) {
historyDAO = new HistoryDAO(trans,this);
}
-
+
String[] helpers = setCRUD(trans, TABLE, Data.class, ArtifactLoader.deflt);
- psByMechID = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
+ psByMechID = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
" WHERE mechid = ?", new ArtifactLoader(1) {
@Override
protected void key(Data data, int idx, Object[] obj) {
@@ -236,7 +236,7 @@ public class ArtiDAO extends CassDAOImpl<AuthzTrans,ArtiDAO.Data> {
}
},readConsistency);
- psByMachine = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
+ psByMachine = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
" WHERE machine = ?", new ArtifactLoader(1) {
@Override
protected void key(Data data, int idx, Object[] obj) {
@@ -244,7 +244,7 @@ public class ArtiDAO extends CassDAOImpl<AuthzTrans,ArtiDAO.Data> {
}
},readConsistency);
- psByNs = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
+ psByNs = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
" WHERE ns = ?", new ArtifactLoader(1) {
@Override
protected void key(Data data, int idx, Object[] obj) {
@@ -253,8 +253,8 @@ public class ArtiDAO extends CassDAOImpl<AuthzTrans,ArtiDAO.Data> {
},readConsistency);
}
-
-
+
+
public Result<List<Data>> readByMechID(AuthzTrans trans, String mechid) {
return psByMechID.read(trans, R_TEXT, new Object[]{mechid});
}
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CacheInfoDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CacheInfoDAO.java
index eea3c4c2..6a32a365 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CacheInfoDAO.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CacheInfoDAO.java
@@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -69,7 +69,7 @@ public class CacheInfoDAO extends CassDAOImpl<AuthzTrans,CacheInfoDAO.Data> impl
public static final Map<String,Date[]> info = new ConcurrentHashMap<>();
private static CacheUpdate cacheUpdate;
-
+
// Hold current time stamps from Tables
private final Date startTime;
private final boolean cacheNotify;
@@ -79,7 +79,7 @@ public class CacheInfoDAO extends CassDAOImpl<AuthzTrans,CacheInfoDAO.Data> impl
// Data Definition, matches Cassandra DM
//////////////////////////////////////////
private static final int KEYLIMIT = 2;
-
+
public CacheInfoDAO(AuthzTrans trans, Cluster cluster, String keyspace) throws APIException, IOException {
super(trans, CacheInfoDAO.class.getSimpleName(),cluster,keyspace,Data.class,TABLE,readConsistency(trans,TABLE), writeConsistency(trans,TABLE));
startTime = new Date();
@@ -94,8 +94,8 @@ public class CacheInfoDAO extends CassDAOImpl<AuthzTrans,CacheInfoDAO.Data> impl
cacheNotify = noK8s(trans);
}
- /**
- * Need a different point to point cache clear strategy for K8s...
+ /**
+ * Need a different point to point cache clear strategy for K8s...
* @param trans
* @return
*/
@@ -124,11 +124,11 @@ public class CacheInfoDAO extends CassDAOImpl<AuthzTrans,CacheInfoDAO.Data> impl
private static class InfoLoader extends Loader<Data> {
public static final InfoLoader dflt = new InfoLoader(KEYLIMIT);
-
+
public InfoLoader(int keylimit) {
super(keylimit);
}
-
+
@Override
public Data load(Data data, Row row) {
// Int more efficient
@@ -151,7 +151,7 @@ public class CacheInfoDAO extends CassDAOImpl<AuthzTrans,CacheInfoDAO.Data> impl
obj[idx]=data.touched;
}
}
-
+
public static synchronized <T extends Trans> void startUpdate(AuthzEnv env, HMangr hman, SecuritySetter<HttpURLConnection> ss, String ip, int port) {
if (cacheUpdate==null) {
cacheUpdate = new CacheUpdate(env,hman,ss, ip,port);
@@ -176,15 +176,15 @@ public class CacheInfoDAO extends CassDAOImpl<AuthzTrans,CacheInfoDAO.Data> impl
private SecuritySetter<HttpURLConnection> ss;
private final String authority;
public boolean go = true;
-
+
public CacheUpdate(AuthzEnv env, HMangr hman, SecuritySetter<HttpURLConnection> ss, String ip, int port) {
this.env = env;
this.hman = hman;
this.ss = ss;
-
+
this.authority = ip+':'+port;
}
-
+
private static class Transfer {
public String table;
public int segs[];
@@ -198,7 +198,7 @@ public class CacheInfoDAO extends CassDAOImpl<AuthzTrans,CacheInfoDAO.Data> impl
private AuthzTrans trans;
private String type;
private String segs;
-
+
public CacheClear(AuthzTrans trans) {
this.trans = trans;
}
@@ -207,7 +207,7 @@ public class CacheInfoDAO extends CassDAOImpl<AuthzTrans,CacheInfoDAO.Data> impl
type = es.getKey();
segs = es.getValue().toString();
}
-
+
@Override
public Integer code(Rcli<?> client) throws APIException, CadiException {
URI to = client.getURI();
@@ -222,11 +222,11 @@ public class CacheInfoDAO extends CassDAOImpl<AuthzTrans,CacheInfoDAO.Data> impl
return total;
}
}
-
+
private class IntHolder {
private int[] raw;
HashSet<Integer> set;
-
+
public IntHolder(int ints[]) {
raw = ints;
set = null;
@@ -234,7 +234,7 @@ public class CacheInfoDAO extends CassDAOImpl<AuthzTrans,CacheInfoDAO.Data> impl
public void add(int[] ints) {
if (set==null) {
set = new HashSet<>();
-
+
for (int i=0;i<raw.length;++i) {
set.add(raw[i]);
}
@@ -270,7 +270,7 @@ public class CacheInfoDAO extends CassDAOImpl<AuthzTrans,CacheInfoDAO.Data> impl
return sb.toString();
}
}
-
+
@Override
public void run() {
do {
@@ -279,7 +279,7 @@ public class CacheInfoDAO extends CassDAOImpl<AuthzTrans,CacheInfoDAO.Data> impl
if (data==null) {
continue;
}
-
+
int count = 0;
CacheClear cc = null;
Map<String,IntHolder> gather = null;
@@ -319,7 +319,7 @@ public class CacheInfoDAO extends CassDAOImpl<AuthzTrans,CacheInfoDAO.Data> impl
sb.append(count);
if (count==1) {
sb.append(" entry for ");
- } else {
+ } else {
sb.append(" entries for ");
}
int peers = count<=0?0:cc.total/count;
@@ -354,13 +354,13 @@ public class CacheInfoDAO extends CassDAOImpl<AuthzTrans,CacheInfoDAO.Data> impl
/* (non-Javadoc)
* @see org.onap.aaf.auth.dao.cass.CIDAO#touch(org.onap.aaf.auth.env.test.AuthzTrans, java.lang.String, int)
*/
-
+
@Override
public Result<Void> touch(AuthzTrans trans, String name, int ... seg) {
/////////////
// Direct Service Cache Invalidation
/////////////
- // ConcurrentQueues are open-ended. We don't want any Memory leaks
+ // ConcurrentQueues are open-ended. We don't want any Memory leaks
// Note: we keep a separate counter, because "size()" on a Linked Queue is expensive
if (cacheNotify && cacheUpdate!=null) {
try {
@@ -389,7 +389,7 @@ public class CacheInfoDAO extends CassDAOImpl<AuthzTrans,CacheInfoDAO.Data> impl
sb.append(name);
sb.append("' AND seg = ");
sb.append(s);
- sb.append(";\n");
+ sb.append(";\n");
if (first) {
first =false;
} else {
@@ -425,7 +425,7 @@ public class CacheInfoDAO extends CassDAOImpl<AuthzTrans,CacheInfoDAO.Data> impl
} finally {
tt.done();
}
-
+
String lastName = null;
Date[] dates = null;
for (Row row : rs.all()) {
@@ -451,7 +451,7 @@ public class CacheInfoDAO extends CassDAOImpl<AuthzTrans,CacheInfoDAO.Data> impl
}
return Result.ok();
}
-
+
/* (non-Javadoc)
* @see org.onap.aaf.auth.dao.cass.CIDAO#get(java.lang.String, int)
*/
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CacheableData.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CacheableData.java
index be7c44ae..0b0ca7fa 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CacheableData.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CacheableData.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,10 +26,10 @@ import org.onap.aaf.auth.dao.Cached;
import org.onap.aaf.auth.dao.CachedDAO;
public abstract class CacheableData implements Cacheable {
- // WARNING: DON'T attempt to add any members here, as it will
+ // WARNING: DON'T attempt to add any members here, as it will
// be treated by system as fields expected in Tables
protected int seg(Cached<?,?> cache, Object ... fields) {
return cache==null?0:cache.invalidate(CachedDAO.keyFromObjs(fields));
}
-
+
}
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CertDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CertDAO.java
index 6c23938f..59248868 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CertDAO.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CertDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -43,18 +43,18 @@ import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Row;
/**
- * CredDAO manages credentials.
+ * CredDAO manages credentials.
* @author Jonathan
* Date: 7/19/13
*/
public class CertDAO extends CassDAOImpl<AuthzTrans,CertDAO.Data> {
public static final String TABLE = "x509";
public static final int CACHE_SEG = 0x40; // yields segment 0x0-0x3F
-
+
private HistoryDAO historyDAO;
private CIDAO<AuthzTrans> infoDAO;
private PSInfo psX500,psID;
-
+
public CertDAO(AuthzTrans trans, Cluster cluster, String keyspace) throws APIException, IOException {
super(trans, CertDAO.class.getSimpleName(),cluster, keyspace, Data.class,TABLE, readConsistency(trans,TABLE), writeConsistency(trans,TABLE));
init(trans);
@@ -66,10 +66,10 @@ public class CertDAO extends CassDAOImpl<AuthzTrans,CertDAO.Data> {
infoDAO = ciDao;
init(trans);
}
-
+
public static final int KEYLIMIT = 2;
public static class Data extends CacheableData implements Bytification {
-
+
public String ca;
public BigInteger serial;
public String id;
@@ -82,14 +82,14 @@ public class CertDAO extends CassDAOImpl<AuthzTrans,CertDAO.Data> {
seg(cache,ca,serial)
};
}
-
+
@Override
public ByteBuffer bytify() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
CertLoader.deflt.marshal(this,new DataOutputStream(baos));
return ByteBuffer.wrap(baos.toByteArray());
}
-
+
@Override
public void reconstitute(ByteBuffer bb) throws IOException {
CertLoader.deflt.unmarshal(this, toDIS(bb));
@@ -99,7 +99,7 @@ public class CertDAO extends CassDAOImpl<AuthzTrans,CertDAO.Data> {
private static class CertLoader extends Loader<Data> implements Streamer<Data>{
public static final int MAGIC=85102934;
public static final int VERSION=1;
- public static final int BUFF_SIZE=48; // Note:
+ public static final int BUFF_SIZE=48; // Note:
public static final CertLoader deflt = new CertLoader(KEYLIMIT);
public CertLoader(int keylimit) {
@@ -133,7 +133,7 @@ public class CertDAO extends CassDAOImpl<AuthzTrans,CertDAO.Data> {
obj[++idx] = data.x500;
obj[++idx] = data.x509;
-
+
}
@Override
@@ -172,7 +172,7 @@ public class CertDAO extends CassDAOImpl<AuthzTrans,CertDAO.Data> {
}
}
}
-
+
public Result<List<CertDAO.Data>> read(AuthzTrans trans, Object ... key) {
// Translate BigInteger to Byte array for lookup
return super.read(trans, key[0],ByteBuffer.wrap(((BigInteger)key[1]).toByteArray()));
@@ -194,9 +194,9 @@ public class CertDAO extends CassDAOImpl<AuthzTrans,CertDAO.Data> {
psX500 = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
" WHERE x500 = ?", CertLoader.deflt,readConsistency);
-
+
}
-
+
public Result<List<Data>> readX500(AuthzTrans trans, String x500) {
return psX500.read(trans, R_TEXT, new Object[]{x500});
}
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ConfigDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ConfigDAO.java
index 9f402adc..1228fce5 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ConfigDAO.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ConfigDAO.java
@@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -40,7 +40,7 @@ import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Row;
/**
- * CredDAO manages credentials.
+ * CredDAO manages credentials.
* @author Jonathan
* Date: 6/25/18
*/
@@ -49,7 +49,7 @@ public class ConfigDAO extends CassDAOImpl<AuthzTrans,ConfigDAO.Data> {
public static final int CACHE_SEG = 0x40; // yields segment 0x0-0x3F
public static final int KEYLIMIT = 2;
private PSInfo psName;
-
+
public ConfigDAO(AuthzTrans trans, Cluster cluster, String keyspace) throws APIException, IOException {
super(trans, ConfigDAO.class.getSimpleName(),cluster, keyspace, Data.class,TABLE_NAME, readConsistency(trans,TABLE_NAME), writeConsistency(trans,TABLE_NAME));
init(trans);
@@ -69,7 +69,7 @@ public class ConfigDAO extends CassDAOImpl<AuthzTrans,ConfigDAO.Data> {
private static class ConfigLoader extends Loader<Data> implements Streamer<Data>{
public static final int MAGIC=2673849;
public static final int VERSION=1;
- public static final int BUFF_SIZE=48;
+ public static final int BUFF_SIZE=48;
public static final ConfigLoader deflt = new ConfigLoader(KEYLIMIT);
public ConfigLoader(int keylimit) {
@@ -113,14 +113,14 @@ public class ConfigDAO extends CassDAOImpl<AuthzTrans,ConfigDAO.Data> {
data.value = readString(is,buff);
}
}
-
+
private void init(AuthzTrans trans) throws APIException, IOException {
String[] helpers = setCRUD(trans, TABLE_NAME, Data.class, ConfigLoader.deflt);
psName = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE_NAME +
" WHERE name = ?", ConfigLoader.deflt,readConsistency);
}
-
+
/**
* Log Modification statements to History
@@ -133,7 +133,7 @@ public class ConfigDAO extends CassDAOImpl<AuthzTrans,ConfigDAO.Data> {
protected void wasModified(AuthzTrans trans, CRUD modified, Data data, String ... override) {
// not an auditable table.
}
-
+
public Result<List<Data>> readName(AuthzTrans trans, String name) {
return psName.read(trans, R_TEXT, new Object[]{name});
}
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CredDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CredDAO.java
index 5acc836e..137969e6 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CredDAO.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CredDAO.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -46,7 +46,7 @@ import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Row;
/**
- * CredDAO manages credentials.
+ * CredDAO manages credentials.
* @author Jonathan
* Date: 7/19/13
*/
@@ -60,13 +60,13 @@ public class CredDAO extends CassDAOImpl<AuthzTrans,CredDAO.Data> {
public static final int BASIC_AUTH_SHA256 = 2;
public static final int CERT_SHA256_RSA =200;
public static final SecureRandom srand = new SecureRandom();
-
+
private HistoryDAO historyDAO;
private CIDAO<AuthzTrans> infoDAO;
private PSInfo psNS;
private PSInfo psID;
private PSInfo psIDBath;
-
+
public CredDAO(AuthzTrans trans, Cluster cluster, String keyspace) throws APIException, IOException {
super(trans, CredDAO.class.getSimpleName(),cluster, keyspace, Data.class,TABLE, readConsistency(trans,TABLE), writeConsistency(trans,TABLE));
init(trans);
@@ -81,7 +81,7 @@ public class CredDAO extends CassDAOImpl<AuthzTrans,CredDAO.Data> {
public static final int KEYLIMIT = 3;
public static class Data extends CacheableData implements Bytification {
-
+
public String id;
public Integer type;
public Date expires;
@@ -98,14 +98,14 @@ public class CredDAO extends CassDAOImpl<AuthzTrans,CredDAO.Data> {
seg(cache,id) // cache is for all entities
};
}
-
+
@Override
public ByteBuffer bytify() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
CredLoader.deflt.marshal(this,new DataOutputStream(baos));
return ByteBuffer.wrap(baos.toByteArray());
}
-
+
@Override
public void reconstitute(ByteBuffer bb) throws IOException {
CredLoader.deflt.unmarshal(this, toDIS(bb));
@@ -119,7 +119,7 @@ public class CredDAO extends CassDAOImpl<AuthzTrans,CredDAO.Data> {
public static class CredLoader extends Loader<Data> implements Streamer<Data>{
public static final int MAGIC=153323443;
public static final int VERSION=2;
- public static final int BUFF_SIZE=48; // Note:
+ public static final int BUFF_SIZE=48; // Note:
public static final CredLoader deflt = new CredLoader(KEYLIMIT);
public CredLoader(int keylimit) {
@@ -132,10 +132,10 @@ public class CredDAO extends CassDAOImpl<AuthzTrans,CredDAO.Data> {
data.type = row.getInt(1); // NOTE: in datastax driver, If the int value is NULL, 0 is returned!
data.expires = row.getTimestamp(2);
data.other = row.getInt(3);
- data.ns = row.getString(4);
+ data.ns = row.getString(4);
data.tag = row.getString(5);
data.notes = row.getString(6);
- data.cred = row.getBytesUnsafe(7);
+ data.cred = row.getBytesUnsafe(7);
return data;
}
@@ -163,7 +163,7 @@ public class CredDAO extends CassDAOImpl<AuthzTrans,CredDAO.Data> {
public void marshal(Data data, DataOutputStream os) throws IOException {
writeHeader(os,MAGIC,VERSION);
writeString(os, data.id);
- os.writeInt(data.type);
+ os.writeInt(data.type);
os.writeLong(data.expires==null?-1:data.expires.getTime());
os.writeInt(data.other==null?0:data.other);
writeString(os, data.ns);
@@ -185,14 +185,14 @@ public class CredDAO extends CassDAOImpl<AuthzTrans,CredDAO.Data> {
byte[] buff = new byte[BUFF_SIZE];
data.id = readString(is,buff);
data.type = is.readInt();
-
+
long l = is.readLong();
data.expires = l<0?null:new Date(l);
data.other = is.readInt();
data.ns = readString(is,buff);
data.tag = readString(is,buff);
data.notes = readString(is,buff);
-
+
int i = is.readInt();
data.cred=null;
if (i>=0) {
@@ -213,16 +213,16 @@ public class CredDAO extends CassDAOImpl<AuthzTrans,CredDAO.Data> {
if (infoDAO==null) {
infoDAO = new CacheInfoDAO(trans,this);
}
-
+
String[] helpers = setCRUD(trans, TABLE, Data.class, CredLoader.deflt);
-
+
psNS = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
" WHERE ns = ?", CredLoader.deflt,readConsistency);
-
+
psID = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
" WHERE id = ?", CredLoader.deflt,readConsistency);
-
+
// NOTE: (type) in ((1),(2)) is valid for Cass 2.1.14. After 2.1.14, more obvious
// syntax of type in (1,2) is available
// ALSO, 1 & 2 STAND FOR BASIC_AUTH (MD5) AND BASIC_AUTH_SHA256(with salt).
@@ -232,7 +232,7 @@ public class CredDAO extends CassDAOImpl<AuthzTrans,CredDAO.Data> {
psIDBath = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
" WHERE id = ? and (type) in ((1),(2))", CredLoader.deflt,readConsistency);
}
-
+
/* (non-Javadoc)
* @see org.onap.aaf.auth.dao.CassDAOImpl#create(org.onap.aaf.misc.env.TransStore, java.lang.Object)
*/
@@ -252,11 +252,11 @@ public class CredDAO extends CassDAOImpl<AuthzTrans,CredDAO.Data> {
public Result<List<Data>> readNS(AuthzTrans trans, String ns) {
return psNS.read(trans, R_TEXT, new Object[]{ns});
}
-
+
public Result<List<Data>> readID(AuthzTrans trans, String id) {
return psID.read(trans, R_TEXT, new Object[]{id});
}
-
+
public Result<List<Data>> readIDBAth(AuthzTrans trans, String id) {
return psIDBath.read(trans, R_TEXT, new Object[] {id});
}
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/DelegateDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/DelegateDAO.java
index e7749bd5..1f7afb8c 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/DelegateDAO.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/DelegateDAO.java
@@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -47,7 +47,7 @@ public class DelegateDAO extends CassDAOImpl<AuthzTrans, DelegateDAO.Data> {
public static final String TABLE = "delegate";
private PSInfo psByDelegate;
private static final int KEYLIMIT = 1;
-
+
public DelegateDAO(AuthzTrans trans, Cluster cluster, String keyspace) {
super(trans, DelegateDAO.class.getSimpleName(),cluster,keyspace,Data.class,TABLE, readConsistency(trans,TABLE), writeConsistency(trans,TABLE));
init(trans);
@@ -57,8 +57,8 @@ public class DelegateDAO extends CassDAOImpl<AuthzTrans, DelegateDAO.Data> {
super(trans, DelegateDAO.class.getSimpleName(),aDao,Data.class,TABLE, readConsistency(trans,TABLE), writeConsistency(trans,TABLE));
init(trans);
}
-
-
+
+
public static class Data implements Bytification {
public String user;
public String delegate;
@@ -70,13 +70,13 @@ public class DelegateDAO extends CassDAOImpl<AuthzTrans, DelegateDAO.Data> {
DelegateLoader.dflt.marshal(this,new DataOutputStream(baos));
return ByteBuffer.wrap(baos.toByteArray());
}
-
+
@Override
public void reconstitute(ByteBuffer bb) throws IOException {
DelegateLoader.dflt.unmarshal(this, toDIS(bb));
}
}
-
+
private static class DelegateLoader extends Loader<Data> implements Streamer<Data>{
public static final int MAGIC=0xD823ACF2;
public static final int VERSION=1;
@@ -87,7 +87,7 @@ public class DelegateDAO extends CassDAOImpl<AuthzTrans, DelegateDAO.Data> {
public DelegateLoader(int keylimit) {
super(keylimit);
}
-
+
@Override
public Data load(Data data, Row row) {
data.user = row.getString(0);
@@ -126,8 +126,8 @@ public class DelegateDAO extends CassDAOImpl<AuthzTrans, DelegateDAO.Data> {
data.delegate = readString(is,buff);
data.expires = new Date(is.readLong());
}
- }
-
+ }
+
private void init(AuthzTrans trans) {
String[] helpers = setCRUD(trans, TABLE, Data.class, DelegateLoader.dflt);
psByDelegate = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/FutureDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/FutureDAO.java
index eafdb884..15c2b557 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/FutureDAO.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/FutureDAO.java
@@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -38,9 +38,9 @@ import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Row;
/**
- * FutureDAO stores Construction information to create
+ * FutureDAO stores Construction information to create
* elements at another time.
- *
+ *
* @author Jonathan
* 8/20/2013
*/
@@ -152,7 +152,7 @@ public class FutureDAO extends CassDAOImpl<AuthzTrans,FutureDAO.Data> {
return Result.err(rs);
}
wasModified(trans, CRUD.create, data, null, id);
- return Result.ok(data);
+ return Result.ok(data);
}
/**
@@ -172,10 +172,10 @@ public class FutureDAO extends CassDAOImpl<AuthzTrans,FutureDAO.Data> {
hd.target = TABLE;
hd.subject = subject?override[1]:"";
hd.memo = memo?String.format("%s by %s", override[0], hd.user):data.memo;
-
+
if (historyDAO.create(trans, hd).status!=Status.OK) {
trans.error().log("Cannot log to History");
}
}
-
+
}
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/HistoryDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/HistoryDAO.java
index 82874ce9..c994dd53 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/HistoryDAO.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/HistoryDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -40,16 +40,16 @@ import com.datastax.driver.core.Row;
/**
* History
- *
+ *
* Originally written PE3617
* @author Jonathan
- *
+ *
* History is a special case, because we don't want Updates or Deletes... Too likely to mess up history.
- *
+ *
* Jonathan 9-9-2013 - Found a problem with using "Prepare". You cannot prepare anything with a "now()" in it, as
* it is evaluated once during the prepare, and kept. That renders any use of "now()" pointless. Therefore
* the Create function needs to be run fresh everytime.
- *
+ *
* Fixed in Cassandra 1.2.6 https://issues.apache.org/jira/browse/CASSANDRA-5616
*
*/
@@ -84,7 +84,7 @@ public class HistoryDAO extends CassDAOImpl<AuthzTrans, HistoryDAO.Data> {
public String memo;
public ByteBuffer reconstruct;
}
-
+
public static class HistLoader extends Loader<Data> {
public HistLoader(int keylimit) {
super(keylimit);
@@ -118,10 +118,10 @@ public class HistoryDAO extends CassDAOImpl<AuthzTrans, HistoryDAO.Data> {
obj[++idx]=data.subject;
obj[++idx]=data.memo;
// obj[++idx]=data.detail;
- obj[++idx]=data.reconstruct;
+ obj[++idx]=data.reconstruct;
}
};
-
+
private void init(AuthzTrans trans) {
// Loader must match fields order
defLoader = new HistLoader(KEYLIMIT);
@@ -130,9 +130,9 @@ public class HistoryDAO extends CassDAOImpl<AuthzTrans, HistoryDAO.Data> {
// Need a specialty Creator to handle the "now()"
// 9/9/2013 - Jonathan - Just great... now() is evaluated once on Client side, invalidating usage (what point is a now() from a long time in the past?
// Unless this is fixed, we're putting in non-prepared statement
- // Solved in Cassandra. Make sure you are running 1.2.6 Cassandra or later. https://issues.apache.org/jira/browse/CASSANDRA-5616
+ // Solved in Cassandra. Make sure you are running 1.2.6 Cassandra or later. https://issues.apache.org/jira/browse/CASSANDRA-5616
replace(CRUD.create, new PSInfo(trans, "INSERT INTO history (" + helpers[FIELD_COMMAS] +
- ") VALUES(now(),?,?,?,?,?,?,?)",
+ ") VALUES(now(),?,?,?,?,?,?,?)",
new HistLoader(0) {
@Override
protected void key(Data data, int idx, Object[] obj) {
@@ -140,9 +140,9 @@ public class HistoryDAO extends CassDAOImpl<AuthzTrans, HistoryDAO.Data> {
},writeConsistency)
);
// disable(CRUD.Create);
-
+
replace(CRUD.read, new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] +
- " FROM history WHERE id = ?", defLoader,readConsistency)
+ " FROM history WHERE id = ?", defLoader,readConsistency)
// new HistLoader(2) {
// @Override
// protected void key(Data data, int idx, Object[] obj) {
@@ -153,12 +153,12 @@ public class HistoryDAO extends CassDAOImpl<AuthzTrans, HistoryDAO.Data> {
);
disable(CRUD.update);
disable(CRUD.delete);
-
- readByUser = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] +
+
+ readByUser = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] +
" FROM history WHERE user = ?", defLoader,readConsistency);
- readBySubject = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] +
+ readBySubject = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] +
" FROM history WHERE subject = ? and target = ? ALLOW FILTERING", defLoader,readConsistency);
- readByYRMN = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] +
+ readByYRMN = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] +
" FROM history WHERE yr_mon = ?", defLoader,readConsistency);
async(true); //TODO dropping messages with Async
}
@@ -169,9 +169,9 @@ public class HistoryDAO extends CassDAOImpl<AuthzTrans, HistoryDAO.Data> {
// Sonar claims that SimpleDateFormat is not thread safe, so we can't be static
data.yr_mon = Integer.parseInt(new SimpleDateFormat("yyyyMM").format(now));
// data.day_time = Integer.parseInt(dayTimeFormat.format(now));
- return data;
+ return data;
}
-
+
public void createBatch(StringBuilder sb, Data data) {
sb.append("INSERT INTO history (");
sb.append(helpers[FIELD_COMMAS]);
@@ -213,7 +213,7 @@ public class HistoryDAO extends CassDAOImpl<AuthzTrans, HistoryDAO.Data> {
}
return extract(defLoader,rs.value,null,yyyymm.length>0?new YYYYMM(yyyymm):dflt);
}
-
+
public Result<List<Data>> readBySubject(AuthzTrans trans, String subject, String target, int ... yyyymm) {
if (yyyymm.length==0) {
return Result.err(Status.ERR_BadData, "No or invalid yyyymm specified");
@@ -224,7 +224,7 @@ public class HistoryDAO extends CassDAOImpl<AuthzTrans, HistoryDAO.Data> {
}
return extract(defLoader,rs.value,null,yyyymm.length>0?new YYYYMM(yyyymm):dflt);
}
-
+
private class YYYYMM implements Accept<Data> {
private int[] yyyymm;
public YYYYMM(int yyyymm[]) {
@@ -240,7 +240,7 @@ public class HistoryDAO extends CassDAOImpl<AuthzTrans, HistoryDAO.Data> {
}
return false;
}
-
+
};
-
+
}
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/LocateDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/LocateDAO.java
index 478cceb0..3fad6a7a 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/LocateDAO.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/LocateDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -44,14 +44,14 @@ import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Row;
/**
- * LocateDAO manages credentials.
+ * LocateDAO manages credentials.
* @author Jonathan
* Date: 10/11/17
*/
public class LocateDAO extends CassDAOImpl<AuthzTrans,LocateDAO.Data> {
public static final String TABLE = "locate";
private AbsCassDAO<AuthzTrans, Data>.PSInfo psName;
-
+
public LocateDAO(AuthzTrans trans, Cluster cluster, String keyspace) throws APIException, IOException {
super(trans, LocateDAO.class.getSimpleName(),cluster, keyspace, Data.class,TABLE, readConsistency(trans,TABLE), writeConsistency(trans,TABLE));
init(trans);
@@ -61,10 +61,10 @@ public class LocateDAO extends CassDAOImpl<AuthzTrans,LocateDAO.Data> {
super(trans, LocateDAO.class.getSimpleName(), adao, Data.class,TABLE, readConsistency(trans,TABLE), writeConsistency(trans,TABLE));
init(trans);
}
-
+
public static final int KEYLIMIT = 3;
public static class Data implements Bytification {
-
+
public String name;
public String hostname;
public int port;
@@ -87,14 +87,14 @@ public class LocateDAO extends CassDAOImpl<AuthzTrans,LocateDAO.Data> {
}
return subprotocol;
}
-
+
@Override
public ByteBuffer bytify() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
LocateLoader.deflt.marshal(this,new DataOutputStream(baos));
return ByteBuffer.wrap(baos.toByteArray());
}
-
+
@Override
public void reconstitute(ByteBuffer bb) throws IOException {
LocateLoader.deflt.unmarshal(this, toDIS(bb));
@@ -122,8 +122,8 @@ public class LocateDAO extends CassDAOImpl<AuthzTrans,LocateDAO.Data> {
private static class LocateLoader extends Loader<Data> implements Streamer<Data>{
public static final int MAGIC=85102934;
public static final int VERSION=1;
- public static final int BUFF_SIZE=48; // Note:
-
+ public static final int BUFF_SIZE=48; // Note:
+
public static final LocateLoader deflt = new LocateLoader(KEYLIMIT);
public LocateLoader(int keylimit) {
super(keylimit);
@@ -188,7 +188,7 @@ public class LocateDAO extends CassDAOImpl<AuthzTrans,LocateDAO.Data> {
writeString(os,s);
}
}
-
+
writeString(os,data.port_key==null?"":data.port_key.toString());
}
@@ -207,7 +207,7 @@ public class LocateDAO extends CassDAOImpl<AuthzTrans,LocateDAO.Data> {
data.latitude = is.readFloat();
data.longitude = is.readFloat();
data.protocol = readString(is,buff);
-
+
int size = is.readInt();
data.subprotocol = new HashSet<>(size);
for (int i=0;i<size;++i) {
@@ -221,7 +221,7 @@ public class LocateDAO extends CassDAOImpl<AuthzTrans,LocateDAO.Data> {
}
}
}
-
+
public Result<List<LocateDAO.Data>> readByName(AuthzTrans trans, String service) {
return psName.read(trans, "Read By Name", new Object[] {service});
}
@@ -235,7 +235,7 @@ public class LocateDAO extends CassDAOImpl<AuthzTrans,LocateDAO.Data> {
psName = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
" WHERE name = ?", new LocateLoader(1),readConsistency);
}
-
+
/**
* Log Modification statements to History
*
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/Namespace.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/Namespace.java
index 192887b9..3e669483 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/Namespace.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/Namespace.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -49,7 +49,7 @@ public class Namespace implements Bytification {
public Integer type;
public String parent;
public Namespace() {}
-
+
public Namespace(NsDAO.Data ndd) {
name = ndd.name;
description = ndd.description;
@@ -62,7 +62,7 @@ public class Namespace implements Bytification {
}
}
}
-
+
public Namespace(NsDAO.Data ndd,List<String> owner, List<String> admin) {
name = ndd.name;
this.owner = owner;
@@ -108,7 +108,7 @@ public class Namespace implements Bytification {
DataInputStream is = CassDAOImpl.toDIS(bb);
/*int version = */Loader.readHeader(is,MAGIC,VERSION);
// If Version Changes between Production runs, you'll need to do a switch Statement, and adequately read in fields
-
+
byte[] buff = new byte[BUFF_SIZE];
name = Loader.readString(is, buff);
type = is.readInt();
@@ -116,7 +116,7 @@ public class Namespace implements Bytification {
owner = Loader.readStringList(is,buff);
description = Loader.readString(is,buff);
parent = Loader.readString(is,buff);
-
+
}
/* (non-Javadoc)
@@ -126,7 +126,7 @@ public class Namespace implements Bytification {
public int hashCode() {
return name.hashCode();
}
-
+
/* (non-Javadoc)
* @see java.lang.Object#toString()
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsDAO.java
index 10e7844c..24bd01de 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsDAO.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -54,9 +54,9 @@ import com.datastax.driver.core.exceptions.DriverException;
/**
* NsDAO
- *
+ *
* Data Access Object for Namespace Data
- *
+ *
* @author Jonathan
*
*/
@@ -73,7 +73,7 @@ public class NsDAO extends CassDAOImpl<AuthzTrans,NsDAO.Data> {
private static final String APPLY_BATCH = "\nAPPLY BATCH;\n";
private static final String SQSCCR = "';\n";
private static final String SQCSQ = "','";
-
+
private HistoryDAO historyDAO;
private CacheInfoDAO infoDAO;
private PSInfo psNS;
@@ -97,7 +97,7 @@ public class NsDAO extends CassDAOImpl<AuthzTrans,NsDAO.Data> {
private static final int KEYLIMIT = 1;
/**
* Data class that matches the Cassandra Table "role"
- *
+ *
* @author Jonathan
*/
public static class Data extends CacheableData implements Bytification {
@@ -135,19 +135,19 @@ public class NsDAO extends CassDAOImpl<AuthzTrans,NsDAO.Data> {
NSLoader.deflt.marshal(this,new DataOutputStream(baos));
return ByteBuffer.wrap(baos.toByteArray());
}
-
+
@Override
public void reconstitute(ByteBuffer bb) throws IOException {
NSLoader.deflt.unmarshal(this,toDIS(bb));
}
-
+
@Override
public String toString() {
return name;
}
-
+
}
-
+
private void init(AuthzTrans trans) throws APIException, IOException {
// Set up sub-DAOs
if (historyDAO==null) {
@@ -158,19 +158,19 @@ public class NsDAO extends CassDAOImpl<AuthzTrans,NsDAO.Data> {
}
String[] helpers = setCRUD(trans, TABLE, Data.class, NSLoader.deflt,4/*need to skip attrib */);
-
+
psNS = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
" WHERE parent = ?", new NSLoader(1),readConsistency);
}
-
+
private static final class NSLoader extends Loader<Data> implements Streamer<Data> {
public static final int MAGIC=250935515;
public static final int VERSION=1;
public static final int BUFF_SIZE=48;
public static final NSLoader deflt = new NSLoader(KEYLIMIT);
-
+
public NSLoader(int keylimit) {
super(keylimit);
}
@@ -198,7 +198,7 @@ public class NsDAO extends CassDAOImpl<AuthzTrans,NsDAO.Data> {
obj[++idx]=data.description;
obj[++idx]=data.parent;
}
-
+
@Override
public void marshal(Data data, DataOutputStream os) throws IOException {
writeHeader(os,MAGIC,VERSION);
@@ -221,7 +221,7 @@ public class NsDAO extends CassDAOImpl<AuthzTrans,NsDAO.Data> {
public void unmarshal(Data data, DataInputStream is) throws IOException {
/*int version = */readHeader(is,MAGIC,VERSION);
// If Version Changes between Production runs, you'll need to do a switch Statement, and adequately read in fields
-
+
byte[] buff = new byte[BUFF_SIZE];
data.name = readString(is, buff);
data.type = is.readInt();
@@ -237,7 +237,7 @@ public class NsDAO extends CassDAOImpl<AuthzTrans,NsDAO.Data> {
}
}
-
+
@Override
public Result<Data> create(AuthzTrans trans, Data data) {
String ns = data.name;
@@ -253,8 +253,8 @@ public class NsDAO extends CassDAOImpl<AuthzTrans,NsDAO.Data> {
stmt.append(APPLY_BATCH);
try {
getSession(trans).execute(stmt.toString());
-//// TEST CODE for Exception
-// boolean force = true;
+//// TEST CODE for Exception
+// boolean force = true;
// if (force) {
// throw new com.datastax.driver.core.exceptions.NoHostAvailableException(new HashMap<>());
//// throw new com.datastax.driver.core.exceptions.AuthenticationException(new InetSocketAddress(9999),"Sample Message");
@@ -293,7 +293,7 @@ public class NsDAO extends CassDAOImpl<AuthzTrans,NsDAO.Data> {
attribUpdateStmt(stmt, ns, es.getKey(),es.getValue());
}
}
-
+
// No point in deleting... insert overwrites...
// for (Entry<String, String> es : remoteAttr.entrySet()) {
// str = localAttr.get(es.getKey());
@@ -320,7 +320,7 @@ public class NsDAO extends CassDAOImpl<AuthzTrans,NsDAO.Data> {
@Override
public Result<List<Data>> read(AuthzTrans trans, Data data) {
Result<List<Data>> rld = super.read(trans, data);
-
+
if (rld.isOKhasData()) {
for (Data d : rld.value) {
// Note: Map is null at this point, save time/mem by assignment
@@ -375,17 +375,17 @@ public class NsDAO extends CassDAOImpl<AuthzTrans,NsDAO.Data> {
return super.delete(trans, data, reread);
}
-
+
public Result<Map<String,String>> readAttribByNS(AuthzTrans trans, String ns) {
Map<String,String> map = new HashMap<>();
TimeTaken tt = trans.start("readAttribByNS " + ns, Env.REMOTE);
try {
- ResultSet rs = getSession(trans).execute("SELECT key,value FROM "
- + TABLE_ATTRIB
+ ResultSet rs = getSession(trans).execute("SELECT key,value FROM "
+ + TABLE_ATTRIB
+ " WHERE ns='"
+ ns
+ "';");
-
+
for (Iterator<Row> iter = rs.iterator();iter.hasNext(); ) {
Row r = iter.next();
map.put(r.getString(0), r.getString(1));
@@ -403,12 +403,12 @@ public class NsDAO extends CassDAOImpl<AuthzTrans,NsDAO.Data> {
Set<String> set = new HashSet<>();
TimeTaken tt = trans.start("readNsBykey " + key, Env.REMOTE);
try {
- ResultSet rs = getSession(trans).execute("SELECT ns FROM "
- + TABLE_ATTRIB
+ ResultSet rs = getSession(trans).execute("SELECT ns FROM "
+ + TABLE_ATTRIB
+ " WHERE key='"
+ key
+ "';");
-
+
for (Iterator<Row> iter = rs.iterator();iter.hasNext(); ) {
Row r = iter.next();
set.add(r.getString(0));
@@ -431,7 +431,7 @@ public class NsDAO extends CassDAOImpl<AuthzTrans,NsDAO.Data> {
return Result.err(Result.ERR_Backend, CassAccess.ERR_ACCESS_MSG);
}
}
-
+
private StringBuilder attribInsertStmt(StringBuilder sb, String ns, String key, String value) {
sb.append("INSERT INTO ");
sb.append(TABLE_ATTRIB);
@@ -457,7 +457,7 @@ public class NsDAO extends CassDAOImpl<AuthzTrans,NsDAO.Data> {
sb.append("';");
return sb;
}
-
+
public Result<Void> attribRemove(AuthzTrans trans, String ns, String key) {
try {
@@ -468,7 +468,7 @@ public class NsDAO extends CassDAOImpl<AuthzTrans,NsDAO.Data> {
return Result.err(Result.ERR_Backend, CassAccess.ERR_ACCESS_MSG);
}
}
-
+
private StringBuilder attribDeleteStmt(StringBuilder stmt, String ns, String key) {
stmt.append("DELETE FROM ");
stmt.append(TABLE_ATTRIB);
@@ -479,7 +479,7 @@ public class NsDAO extends CassDAOImpl<AuthzTrans,NsDAO.Data> {
stmt.append("';");
return stmt;
}
-
+
private void attribDeleteAllStmt(StringBuilder stmt, Data data) {
stmt.append(" DELETE FROM ");
stmt.append(TABLE_ATTRIB);
@@ -505,7 +505,7 @@ public class NsDAO extends CassDAOImpl<AuthzTrans,NsDAO.Data> {
*/
public Result<Void> addDescription(AuthzTrans trans, String ns, String description) {
try {
- getSession(trans).execute(UPDATE_SP + TABLE + " SET description = '"
+ getSession(trans).execute(UPDATE_SP + TABLE + " SET description = '"
+ description.replace("'", "''") + "' WHERE name = '" + ns + "';");
} catch (DriverException | APIException | IOException e) {
reportPerhapsReset(trans,e);
@@ -521,11 +521,11 @@ public class NsDAO extends CassDAOImpl<AuthzTrans,NsDAO.Data> {
public Result<List<Data>> getChildren(AuthzTrans trans, String parent) {
return psNS.read(trans, R_TEXT, new Object[]{parent});
}
-
+
/**
* Log Modification statements to History
- *
+ *
* @param modified which CRUD action was done
* @param data entity data that needs a log entry
* @param overrideMessage if this is specified, we use it rather than crafting a history message based on data
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsSplit.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsSplit.java
index 2beeaf38..017c813a 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsSplit.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsSplit.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,7 +25,7 @@ public class NsSplit {
public final String ns;
public final String name;
public final NsDAO.Data nsd;
-
+
public NsSplit(NsDAO.Data nsd, String child) {
this.nsd = nsd;
if (child.startsWith(nsd.name)) {
@@ -41,7 +41,7 @@ public class NsSplit {
ns = null;
}
}
-
+
public NsSplit(String ns, String name) {
this.ns = ns;
this.name = name;
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsType.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsType.java
index e656a555..bc7aa227 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsType.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsType.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,19 +29,19 @@ package org.onap.aaf.auth.dao.cass;
public enum NsType {
UNKNOWN (-1),
DOT (0),
- ROOT (1),
- COMPANY (2),
- APP (3),
- STACKED_APP (10),
+ ROOT (1),
+ COMPANY (2),
+ APP (3),
+ STACKED_APP (10),
STACK (11);
-
+
public final int type;
private NsType(int t) {
type = t;
}
/**
* This is not the Ordinal, but the Type that is stored in NS Tables
- *
+ *
* @param t
* @return
*/
@@ -53,7 +53,7 @@ public enum NsType {
}
return UNKNOWN;
}
-
+
/**
* Use this one rather than "valueOf" to avoid Exception
* @param s
@@ -70,5 +70,5 @@ public enum NsType {
return UNKNOWN;
}
-
+
}
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/OAuthTokenDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/OAuthTokenDAO.java
index 5d0f084b..a84490d0 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/OAuthTokenDAO.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/OAuthTokenDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -44,19 +44,19 @@ import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Row;
/**
- * CredDAO manages credentials.
+ * CredDAO manages credentials.
* @author Jonathan
* Date: 7/19/13
*/
public class OAuthTokenDAO extends CassDAOImpl<AuthzTrans,OAuthTokenDAO.Data> {
public static final String TABLE = "oauth_token";
private AbsCassDAO<AuthzTrans, Data>.PSInfo psByUser;
-
+
public OAuthTokenDAO(AuthzTrans trans, Cluster cluster, String keyspace) {
super(trans, OAuthTokenDAO.class.getSimpleName(),cluster, keyspace, Data.class,TABLE, readConsistency(trans,TABLE), writeConsistency(trans,TABLE));
init(trans);
}
-
+
public OAuthTokenDAO(AuthzTrans trans, AbsCassDAO<AuthzTrans,?> aDao) {
super(trans, OAuthTokenDAO.class.getSimpleName(),aDao, Data.class, TABLE, readConsistency(trans,TABLE), writeConsistency(trans,TABLE));
init(trans);
@@ -73,7 +73,7 @@ public class OAuthTokenDAO extends CassDAOImpl<AuthzTrans,OAuthTokenDAO.Data> {
public String refresh;
public Date expires;
public long exp_sec;
- public String content;
+ public String content;
public Set<String> scopes;
public String state;
public String req_ip; // requesting
@@ -93,7 +93,7 @@ public class OAuthTokenDAO extends CassDAOImpl<AuthzTrans,OAuthTokenDAO.Data> {
OAuthLoader.deflt.marshal(this,new DataOutputStream(baos));
return ByteBuffer.wrap(baos.toByteArray());
}
-
+
@Override
public void reconstitute(ByteBuffer bb) throws IOException {
OAuthLoader.deflt.unmarshal(this, toDIS(bb));
@@ -107,13 +107,13 @@ public class OAuthTokenDAO extends CassDAOImpl<AuthzTrans,OAuthTokenDAO.Data> {
private static class OAuthLoader extends Loader<Data> implements Streamer<Data>{
public static final int MAGIC=235677843;
public static final int VERSION=1;
- public static final int BUFF_SIZE=96; // Note: only used when
-
+ public static final int BUFF_SIZE=96; // Note: only used when
+
public static final OAuthLoader deflt = new OAuthLoader(KEYLIMIT);
public OAuthLoader(int keylimit) {
super(keylimit);
}
-
+
@Override
public Data load(Data data, Row row) {
data.id = row.getString(0);
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/PermDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/PermDAO.java
index 699d6e28..a59682c4 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/PermDAO.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/PermDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -53,10 +53,10 @@ public class PermDAO extends CassDAOImpl<AuthzTrans,PermDAO.Data> {
public static final int CACHE_SEG = 0x40; // yields segment 0x0-0x3F
private static final String STAR = "*";
-
+
private final HistoryDAO historyDAO;
private final CacheInfoDAO infoDAO;
-
+
private PSInfo psNS, psChildren, psByType;
public PermDAO(AuthzTrans trans, Cluster cluster, String keyspace) throws APIException, IOException {
@@ -80,11 +80,11 @@ public class PermDAO extends CassDAOImpl<AuthzTrans,PermDAO.Data> {
public String type;
public String instance;
public String action;
- public Set<String> roles;
+ public Set<String> roles;
public String description;
public Data() {}
-
+
public Data(NsSplit nss, String instance, String action) {
ns = nss.ns;
type = nss.name;
@@ -103,7 +103,7 @@ public class PermDAO extends CassDAOImpl<AuthzTrans,PermDAO.Data> {
sb.append(type);
return sb.toString();
}
-
+
public String fullPerm() {
StringBuilder sb = new StringBuilder();
if(ns==null) {
@@ -123,10 +123,10 @@ public class PermDAO extends CassDAOImpl<AuthzTrans,PermDAO.Data> {
public String encode() {
return ns + '|' + type + '|' + instance + '|' + action;
}
-
+
/**
* Decode Perm String, including breaking into appropriate Namespace
- *
+ *
* @param trans
* @param q
* @param p
@@ -158,7 +158,7 @@ public class PermDAO extends CassDAOImpl<AuthzTrans,PermDAO.Data> {
/**
* Decode Perm String, including breaking into appropriate Namespace
- *
+ *
* @param trans
* @param q
* @param p
@@ -169,7 +169,7 @@ public class PermDAO extends CassDAOImpl<AuthzTrans,PermDAO.Data> {
if (ss[2]==null) {
return Result.err(Status.ERR_BadData,"Perm Encodings must be separated by '|'");
}
-
+
if (ss[3]==null) { // older 3 part encoding must be evaluated for NS
ss[3] = ss[2];
ss[2] = ss[1];
@@ -206,7 +206,7 @@ public class PermDAO extends CassDAOImpl<AuthzTrans,PermDAO.Data> {
}
return rv;
}
-
+
public static Data create(AuthzTrans trans, Question q, String name) {
String[] s = name.split("\\|");
Result<NsSplit> rdns = q.deriveNsSplit(trans, s[0]);
@@ -240,7 +240,7 @@ public class PermDAO extends CassDAOImpl<AuthzTrans,PermDAO.Data> {
}
return rv;
}
-
+
////////////////////////////////////////
// Getters
public Set<String> roles(boolean mutable) {
@@ -268,7 +268,7 @@ public class PermDAO extends CassDAOImpl<AuthzTrans,PermDAO.Data> {
PermLoader.deflt.marshal(this, new DataOutputStream(baos));
return ByteBuffer.wrap(baos.toByteArray());
}
-
+
@Override
public void reconstitute(ByteBuffer bb) throws IOException {
PermLoader.deflt.unmarshal(this, toDIS(bb));
@@ -279,18 +279,18 @@ public class PermDAO extends CassDAOImpl<AuthzTrans,PermDAO.Data> {
return encode();
}
}
-
+
private static class PermLoader extends Loader<Data> implements Streamer<Data> {
public static final int MAGIC=283939453;
public static final int VERSION=1;
public static final int BUFF_SIZE=96;
public static final PermLoader deflt = new PermLoader(KEYLIMIT);
-
+
public PermLoader(int keylimit) {
super(keylimit);
}
-
+
@Override
public Data load(Data data, Row row) {
// Int more efficient Match "fields" string
@@ -343,25 +343,25 @@ public class PermDAO extends CassDAOImpl<AuthzTrans,PermDAO.Data> {
data.description = readString(is,buff);
}
}
-
+
private void init(AuthzTrans trans) {
// the 3 is the number of key fields
String[] helpers = setCRUD(trans, TABLE, Data.class, PermLoader.deflt);
-
+
// Other SELECT style statements... match with a local Method
- psByType = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
+ psByType = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
" WHERE ns = ? AND type = ?", new PermLoader(2) {
@Override
protected void key(Data data, int idx, Object[] obj) {
obj[idx]=data.type;
}
},readConsistency);
-
+
psNS = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
" WHERE ns = ?", new PermLoader(1),readConsistency);
-
- psChildren = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
- " WHERE ns=? AND type > ? AND type < ?",
+
+ psChildren = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
+ " WHERE ns=? AND type > ? AND type < ?",
new PermLoader(3) {
@Override
protected void key(Data data, int _idx, Object[] obj) {
@@ -377,7 +377,7 @@ public class PermDAO extends CassDAOImpl<AuthzTrans,PermDAO.Data> {
/**
* Add a single Permission to the Role's Permission Collection
- *
+ *
* @param trans
* @param roleFullName
* @param perm
@@ -438,11 +438,11 @@ public class PermDAO extends CassDAOImpl<AuthzTrans,PermDAO.Data> {
}
-
+
/**
- * Additional method:
+ * Additional method:
* Select all Permissions by Name
- *
+ *
* @param name
* @return
* @throws DAOException
@@ -450,7 +450,7 @@ public class PermDAO extends CassDAOImpl<AuthzTrans,PermDAO.Data> {
public Result<List<Data>> readByType(AuthzTrans trans, String ns, String type) {
return psByType.read(trans, R_TEXT, new Object[]{ns, type});
}
-
+
public Result<List<Data>> readChildren(AuthzTrans trans, String ns, String type) {
return psChildren.read(trans, R_TEXT, new Object[]{ns, type+DOT, type + DOT_PLUS_ONE});
}
@@ -461,7 +461,7 @@ public class PermDAO extends CassDAOImpl<AuthzTrans,PermDAO.Data> {
/**
* Add description to this permission
- *
+ *
* @param trans
* @param ns
* @param type
@@ -473,7 +473,7 @@ public class PermDAO extends CassDAOImpl<AuthzTrans,PermDAO.Data> {
public Result<Void> addDescription(AuthzTrans trans, String ns, String type,
String instance, String action, String description) {
try {
- getSession(trans).execute(UPDATE_SP + TABLE + " SET description = '"
+ getSession(trans).execute(UPDATE_SP + TABLE + " SET description = '"
+ description + "' WHERE ns = '" + ns + "' AND type = '" + type + "'"
+ "AND instance = '" + instance + "' AND action = '" + action + "';");
} catch (DriverException | APIException | IOException e) {
@@ -486,11 +486,11 @@ public class PermDAO extends CassDAOImpl<AuthzTrans,PermDAO.Data> {
data.type=type;
data.instance=instance;
data.action=action;
- wasModified(trans, CRUD.update, data, "Added description " + description + " to permission "
+ wasModified(trans, CRUD.update, data, "Added description " + description + " to permission "
+ data.encode(), null );
return Result.ok();
}
-
+
/**
* Log Modification statements to History
*/
@@ -510,7 +510,7 @@ public class PermDAO extends CassDAOImpl<AuthzTrans,PermDAO.Data> {
} else {
hd.memo = String.format("%sd %s|%s|%s", modified.name(),data.fullType(),data.instance,data.action);
}
-
+
if (modified==CRUD.delete) {
try {
hd.reconstruct = data.bytify();
@@ -518,7 +518,7 @@ public class PermDAO extends CassDAOImpl<AuthzTrans,PermDAO.Data> {
trans.error().log(e,"Could not serialize PermDAO.Data");
}
}
-
+
if (historyDAO.create(trans, hd).status!=Status.OK) {
trans.error().log("Cannot log to History");
}
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/RoleDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/RoleDAO.java
index e5c97559..ae8d525d 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/RoleDAO.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/RoleDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -50,7 +50,7 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
public static final String TABLE = "role";
public static final int CACHE_SEG = 0x40; // yields segment 0x0-0x3F
-
+
private final HistoryDAO historyDAO;
private final CacheInfoDAO infoDAO;
@@ -96,34 +96,34 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
}
return perms;
}
-
+
public static Data create(NsDAO.Data ns, String name) {
- NsSplit nss = new NsSplit(ns,name);
+ NsSplit nss = new NsSplit(ns,name);
RoleDAO.Data rv = new Data();
rv.ns = nss.ns;
rv.name=nss.name;
return rv;
}
-
+
public String fullName() {
StringBuilder sb = new StringBuilder();
if(ns==null) {
sb.append('.');
} else {
sb.append(ns);
- sb.append(ns.indexOf('@')<0?'.':':');
+ sb.append(ns.indexOf('@')<0?'.':':');
}
sb.append(name);
return sb.toString();
}
-
+
public String encode() {
return ns + '|' + name;
}
-
+
/**
* Decode Perm String, including breaking into appropriate Namespace
- *
+ *
* @param trans
* @param q
* @param r
@@ -171,7 +171,7 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
/**
* Decode Perm String, including breaking into appropriate Namespace
- *
+ *
* @param trans
* @param q
* @param p
@@ -189,7 +189,7 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
}
return Result.ok(ss);
}
-
+
@Override
public int[] invalidate(Cached<?,?> cache) {
return new int[] {
@@ -205,7 +205,7 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
RoleLoader.deflt.marshal(this,new DataOutputStream(baos));
return ByteBuffer.wrap(baos.toByteArray());
}
-
+
@Override
public void reconstitute(ByteBuffer bb) throws IOException {
RoleLoader.deflt.unmarshal(this, toDIS(bb));
@@ -223,11 +223,11 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
public static final int BUFF_SIZE=96;
public static final RoleLoader deflt = new RoleLoader(KEYLIMIT);
-
+
public RoleLoader(int keylimit) {
super(keylimit);
}
-
+
@Override
public Data load(Data data, Row row) {
// Int more efficient
@@ -275,15 +275,15 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
private void init(AuthzTrans trans) {
String[] helpers = setCRUD(trans, TABLE, Data.class, RoleLoader.deflt);
-
+
psNS = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
" WHERE ns = ?", new RoleLoader(1),readConsistency);
psName = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
" WHERE name = ?", new RoleLoader(1),readConsistency);
- psChildren = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
- " WHERE ns=? AND name > ? AND name < ?",
+ psChildren = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
+ " WHERE ns=? AND name > ? AND name < ?",
new RoleLoader(3) {
@Override
protected void key(Data data, int _idx, Object[] obj) {
@@ -293,7 +293,7 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
obj[++idx]=data.name + DOT_PLUS_ONE;
}
},readConsistency);
-
+
}
public Result<List<Data>> readNS(AuthzTrans trans, String ns) {
@@ -306,7 +306,7 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
public Result<List<Data>> readChildren(AuthzTrans trans, String ns, String role) {
if (role.length()==0 || "*".equals(role)) {
- return psChildren.read(trans, R_TEXT, new Object[]{ns, FIRST_CHAR, LAST_CHAR});
+ return psChildren.read(trans, R_TEXT, new Object[]{ns, FIRST_CHAR, LAST_CHAR});
} else {
return psChildren.read(trans, R_TEXT, new Object[]{ns, role+DOT, role+DOT_PLUS_ONE});
}
@@ -314,7 +314,7 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
/**
* Add a single Permission to the Role's Permission Collection
- *
+ *
* @param trans
* @param role
* @param perm
@@ -326,7 +326,7 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
// Note: Prepared Statements for Collection updates aren't supported
String pencode = perm.encode();
try {
- getSession(trans).execute(UPDATE_SP + TABLE + " SET perms = perms + {'" +
+ getSession(trans).execute(UPDATE_SP + TABLE + " SET perms = perms + {'" +
pencode + "'} WHERE " +
"ns = '" + role.ns + "' AND name = '" + role.name + "';");
} catch (DriverException | APIException | IOException e) {
@@ -351,10 +351,10 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
// Note: Prepared Statements for Collection updates aren't supported
String pencode = perm.encode();
-
+
//ResultSet rv =
try {
- getSession(trans).execute(UPDATE_SP + TABLE + " SET perms = perms - {'" +
+ getSession(trans).execute(UPDATE_SP + TABLE + " SET perms = perms - {'" +
pencode + "'} WHERE " +
"ns = '" + role.ns + "' AND name = '" + role.name + "';");
} catch (DriverException | APIException | IOException e) {
@@ -366,10 +366,10 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
wasModified(trans, CRUD.update, role, "Removed permission " + pencode + " from role " + role.fullName() );
return Result.ok();
}
-
+
/**
* Add description to role
- *
+ *
* @param trans
* @param ns
* @param name
@@ -378,7 +378,7 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
*/
public Result<Void> addDescription(AuthzTrans trans, String ns, String name, String description) {
try {
- getSession(trans).execute(UPDATE_SP + TABLE + " SET description = '"
+ getSession(trans).execute(UPDATE_SP + TABLE + " SET description = '"
+ description + "' WHERE ns = '" + ns + "' AND name = '" + name + "';");
} catch (DriverException | APIException | IOException e) {
reportPerhapsReset(trans,e);
@@ -391,8 +391,8 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
wasModified(trans, CRUD.update, data, "Added description " + description + " to role " + data.fullName(), null );
return Result.ok();
}
-
-
+
+
/**
* Log Modification statements to History
* @param modified which CRUD action was done
@@ -426,5 +426,5 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
}
}
-
+
} \ No newline at end of file
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/Status.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/Status.java
index a4d0bf4d..3a05eb31 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/Status.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/Status.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,7 +28,7 @@ import org.onap.aaf.auth.layer.Result;
/**
* Add additional Behavior for Specific Applications for Results
- *
+ *
* In this case, we add additional BitField information accessible by
* method (
* @author Jonathan
@@ -36,11 +36,11 @@ import org.onap.aaf.auth.layer.Result;
* @param <RV>
*/
public class Status<RV> extends Result<RV> {
-
+
// Jonathan 10/1/2013: Initially, I used enum, but it's not extensible.
public final static int ERR_NsNotFound = Result.ERR_General+1,
ERR_RoleNotFound = Result.ERR_General+2,
- ERR_PermissionNotFound = Result.ERR_General+3,
+ ERR_PermissionNotFound = Result.ERR_General+3,
ERR_UserNotFound = Result.ERR_General+4,
ERR_UserRoleNotFound = Result.ERR_General+5,
ERR_DelegateNotFound = Result.ERR_General+6,
@@ -51,9 +51,9 @@ public class Status<RV> extends Result<RV> {
ACC_Future = Result.ERR_General+11,
ERR_ChoiceNeeded = Result.ERR_General+12,
ERR_FutureNotRequested = Result.ERR_General+13;
-
+
/**
- * Constructor for Result set.
+ * Constructor for Result set.
* @param data
* @param status
*/
@@ -66,7 +66,7 @@ public class Status<RV> extends Result<RV> {
case OK: return "OK";
case ERR_NsNotFound: return "ERR_NsNotFound";
case ERR_RoleNotFound: return "ERR_RoleNotFound";
- case ERR_PermissionNotFound: return "ERR_PermissionNotFound";
+ case ERR_PermissionNotFound: return "ERR_PermissionNotFound";
case ERR_UserNotFound: return "ERR_UserNotFound";
case ERR_UserRoleNotFound: return "ERR_UserRoleNotFound";
case ERR_DelegateNotFound: return "ERR_DelegateNotFound";
@@ -81,8 +81,8 @@ public class Status<RV> extends Result<RV> {
case ERR_NotFound: return "ERR_NotFound";
case ERR_ChoiceNeeded: return "ERR_ChoiceNeeded";
}
- //case ERR_General: or unknown...
+ //case ERR_General: or unknown...
return "ERR_General";
}
-
+
}
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/UserRoleDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/UserRoleDAO.java
index b6cbcf82..813f55ac 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/UserRoleDAO.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/UserRoleDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -47,15 +47,15 @@ import com.datastax.driver.core.Row;
public class UserRoleDAO extends CassDAOImpl<AuthzTrans,UserRoleDAO.Data> {
public static final String TABLE = "user_role";
-
+
public static final int CACHE_SEG = 0x40; // yields segment 0x0-0x3F
private static final String TRANS_UR_SLOT = "_TRANS_UR_SLOT_";
public Slot transURSlot;
-
+
private final HistoryDAO historyDAO;
private final CacheInfoDAO infoDAO;
-
+
private PSInfo psByUser, psByRole, psUserInRole;
@@ -82,10 +82,10 @@ public class UserRoleDAO extends CassDAOImpl<AuthzTrans,UserRoleDAO.Data> {
public static class Data extends CacheableData implements Bytification {
public String user;
public String role;
- public String ns;
- public String rname;
+ public String ns;
+ public String rname;
public Date expires;
-
+
@Override
public int[] invalidate(Cached<?,?> cache) {
// Note: I'm not worried about Name collisions, because the formats are different:
@@ -105,7 +105,7 @@ public class UserRoleDAO extends CassDAOImpl<AuthzTrans,UserRoleDAO.Data> {
URLoader.deflt.marshal(this,new DataOutputStream(baos));
return ByteBuffer.wrap(baos.toByteArray());
}
-
+
@Override
public void reconstitute(ByteBuffer bb) throws IOException {
URLoader.deflt.unmarshal(this, toDIS(bb));
@@ -116,14 +116,14 @@ public class UserRoleDAO extends CassDAOImpl<AuthzTrans,UserRoleDAO.Data> {
this.rname = rname;
this.role = ns + '.' + rname;
}
-
+
public void role(RoleDAO.Data rdd) {
ns = rdd.ns;
rname = rdd.name;
role = rdd.fullName();
}
-
+
public boolean role(AuthzTrans trans, Question ques, String role) {
this.role = role;
Result<NsSplit> rnss = ques.deriveNsSplit(trans, role);
@@ -141,12 +141,12 @@ public class UserRoleDAO extends CassDAOImpl<AuthzTrans,UserRoleDAO.Data> {
return user + '|' + ns + '|' + rname + '|' + Chrono.dateStamp(expires);
}
}
-
+
private static class URLoader extends Loader<Data> implements Streamer<Data> {
public static final int MAGIC=738469903;
public static final int VERSION=1;
public static final int BUFF_SIZE=48;
-
+
public static final URLoader deflt = new URLoader(KEYLIMIT);
public URLoader(int keylimit) {
@@ -177,7 +177,7 @@ public class UserRoleDAO extends CassDAOImpl<AuthzTrans,UserRoleDAO.Data> {
obj[++idx]=data.rname;
obj[++idx]=data.expires;
}
-
+
@Override
public void marshal(Data data, DataOutputStream os) throws IOException {
writeHeader(os,MAGIC,VERSION);
@@ -193,7 +193,7 @@ public class UserRoleDAO extends CassDAOImpl<AuthzTrans,UserRoleDAO.Data> {
public void unmarshal(Data data, DataInputStream is) throws IOException {
/*int version = */readHeader(is,MAGIC,VERSION);
// If Version Changes between Production runs, you'll need to do a switch Statement, and adequately read in fields
-
+
byte[] buff = new byte[BUFF_SIZE];
data.user = readString(is,buff);
data.role = readString(is,buff);
@@ -204,27 +204,27 @@ public class UserRoleDAO extends CassDAOImpl<AuthzTrans,UserRoleDAO.Data> {
}
};
-
+
private void init(AuthzTrans trans) {
String[] helper = setCRUD(trans, TABLE, Data.class, URLoader.deflt);
-
- psByUser = new PSInfo(trans, SELECT_SP + helper[FIELD_COMMAS] + " FROM user_role WHERE user = ?",
+
+ psByUser = new PSInfo(trans, SELECT_SP + helper[FIELD_COMMAS] + " FROM user_role WHERE user = ?",
new URLoader(1) {
@Override
protected void key(Data data, int idx, Object[] obj) {
obj[idx]=data.user;
}
},readConsistency);
-
+
// Note: We understand this call may have poor performance, so only should be used in Management (Delete) func
- psByRole = new PSInfo(trans, SELECT_SP + helper[FIELD_COMMAS] + " FROM user_role WHERE role = ? ALLOW FILTERING",
+ psByRole = new PSInfo(trans, SELECT_SP + helper[FIELD_COMMAS] + " FROM user_role WHERE role = ? ALLOW FILTERING",
new URLoader(1) {
@Override
protected void key(Data data, int idx, Object[] obj) {
obj[idx]=data.role;
}
},readConsistency);
-
+
psUserInRole = new PSInfo(trans,SELECT_SP + helper[FIELD_COMMAS] + " FROM user_role WHERE user = ? AND role = ?",
URLoader.deflt,readConsistency);
}
@@ -243,7 +243,7 @@ public class UserRoleDAO extends CassDAOImpl<AuthzTrans,UserRoleDAO.Data> {
public Result<List<Data>> readByRole(AuthzTrans trans, String role) {
return psByRole.read(trans, R_TEXT + " by Role " + role, new Object[]{role});
}
-
+
/**
* Direct Lookup of User Role
* Don't forget to check for Expiration
@@ -266,7 +266,7 @@ public class UserRoleDAO extends CassDAOImpl<AuthzTrans,UserRoleDAO.Data> {
HistoryDAO.Data hd = HistoryDAO.newInitedData();
HistoryDAO.Data hdRole = HistoryDAO.newInitedData();
-
+
hd.user = hdRole.user = trans.user();
hd.action = modified.name();
// Modifying User/Role is an Update to Role, not a Create. Jonathan, 07-14-2015
@@ -276,17 +276,17 @@ public class UserRoleDAO extends CassDAOImpl<AuthzTrans,UserRoleDAO.Data> {
hd.subject = subject?override[1] : (data.user + '|'+data.role);
hdRole.subject = data.role;
switch(modified) {
- case create:
+ case create:
hd.memo = hdRole.memo = memo
? String.format("%s by %s", override[0], hd.user)
- : String.format("%s added to %s",data.user,data.role);
+ : String.format("%s added to %s",data.user,data.role);
break;
- case update:
+ case update:
hd.memo = hdRole.memo = memo
? String.format("%s by %s", override[0], hd.user)
: String.format("%s - %s was updated",data.user,data.role);
break;
- case delete:
+ case delete:
hd.memo = hdRole.memo = memo
? String.format("%s by %s", override[0], hd.user)
: String.format("%s removed from %s",data.user,data.role);
@@ -305,7 +305,7 @@ public class UserRoleDAO extends CassDAOImpl<AuthzTrans,UserRoleDAO.Data> {
if (historyDAO.create(trans, hd).status!=Status.OK) {
trans.error().log("Cannot log to History");
}
-
+
if (historyDAO.create(trans, hdRole).status!=Status.OK) {
trans.error().log("Cannot log to History");
}
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/CassExecutor.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/CassExecutor.java
index a92de21c..27a18821 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/CassExecutor.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/CassExecutor.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Function.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Function.java
index dd367c51..d8096188 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Function.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Function.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -64,17 +64,17 @@ public class Function {
public enum FUTURE_OP {
C("Create"),U("Update"),D("Delete"),G("Grant"),UG("UnGrant"),A("Approval");
-
+
private String desc;
-
+
private FUTURE_OP(String desc) {
this.desc = desc;
}
-
+
public String desc() {
return desc;
}
-
+
/**
* Same as valueOf(), but passes back null instead of throwing Exception
* @param value
@@ -94,7 +94,7 @@ public class Function {
public enum OP_STATUS {
E("Executed"),D("Denied"),P("Pending"),L("Lapsed");
-
+
private String desc;
public final static Result<OP_STATUS> RE = Result.ok(OP_STATUS.E);
public final static Result<OP_STATUS> RD = Result.ok(OP_STATUS.D);
@@ -104,11 +104,11 @@ public class Function {
private OP_STATUS(String desc) {
this.desc = desc;
}
-
+
public String desc() {
return desc;
}
-
+
}
public static final String FOP_CRED = "cred";
@@ -159,16 +159,16 @@ public class Function {
/**
* createNS
- *
+ *
* Create Namespace
- *
+ *
* @param trans
* @param org
* @param ns
* @param user
* @return
* @throws DAOException
- *
+ *
* To create an NS, you need to: 1) validate permission to
* modify parent NS 2) Does NS exist already? 3) Create NS with
* a) "user" as owner. NOTE: Per 10-15 request for AAF 1.0 4)
@@ -185,7 +185,7 @@ public class Function {
Identity orgUser = org.getIdentity(trans, u);
String reason;
if (orgUser == null) {
- return Result.err(Status.ERR_Policy,"%s is not a valid user at %s",u,org.getName());
+ return Result.err(Status.ERR_Policy,"%s is not a valid user at %s",u,org.getName());
} else if ((reason=orgUser.mayOwn())!=null) {
if (org.isTestEnv()) {
String reason2;
@@ -242,7 +242,7 @@ public class Function {
return Result.err(Status.ERR_ConflictAlreadyExists,
"Target Namespace already exists");
}
-
+
// 2.1) Does role exist with that name
if(cname!=null && q.roleDAO().read(trans, parent, cname).isOKhasData()) {
return Result.err(Status.ERR_ConflictAlreadyExists,
@@ -347,7 +347,7 @@ public class Function {
trans.error().log(rpdd.errorString());
}
}
-
+
// Save off Old keys
String delP1 = rdd.ns;
String delP2 = rdd.name;
@@ -356,7 +356,7 @@ public class Function {
rdd.ns = namespace.name;
rdd.name = (delP2.length() > targetNameDot) ? delP2
.substring(targetNameDot) : "";
-
+
// Need to use non-cached, because switching namespaces, not
// "create" per se
if ((rq = q.roleDAO().create(trans, rdd)).isOK()) {
@@ -364,7 +364,7 @@ public class Function {
for (PermDAO.Data pdd : lpdd) {
q.permDAO().addRole(trans, pdd, rdd);
}
- // Change data for User Roles
+ // Change data for User Roles
Result<List<UserRoleDAO.Data>> rurd = q.userRoleDAO().readByRole(trans, rdd.fullName());
if (rurd.isOKhasData()) {
for (UserRoleDAO.Data urd : rurd.value) {
@@ -391,7 +391,7 @@ public class Function {
for (PermDAO.Data pdd : rpdc.value) {
// Remove old Perm from Roles, save them off
List<RoleDAO.Data> lrdd = new ArrayList<>();
-
+
for (String rl : pdd.roles(false)) {
Result<RoleDAO.Data> rrdd = RoleDAO.Data.decode(trans,q,rl);
if (rrdd.isOKhasData()) {
@@ -402,7 +402,7 @@ public class Function {
trans.error().log(rrdd.errorString());
}
}
-
+
// Save off Old keys
String delP1 = pdd.ns;
String delP2 = pdd.type;
@@ -481,9 +481,9 @@ public class Function {
/**
* deleteNS
- *
+ *
* Delete Namespace
- *
+ *
* @param trans
* @param org
* @param ns
@@ -491,8 +491,8 @@ public class Function {
* @param user
* @return
* @throws DAOException
- *
- *
+ *
+ *
* To delete an NS, you need to: 1) validate permission to
* modify this NS 2) Find all Roles with this NS, and 2a) if
* Force, delete them, else modify to Parent NS 3) Find all
@@ -723,7 +723,7 @@ public class Function {
if (rq.notOK()) {
return Result.err(rq);
}
-
+
rq = q.mayUser(trans, trans.user(), rq.value, Access.write);
if (rq.notOK()) {
Result<List<UserRoleDAO.Data>> ruinr = q.userRoleDAO().readUserInRole(trans, trans.user(),ns+".owner");
@@ -757,7 +757,7 @@ public class Function {
return Result.err(Status.ERR_Security,
"%s is not a valid AAF Credential", user);
}
-
+
for (CredDAO.Data cd : cdr.value) {
if (cd.expires.after(now)) {
return Result.ok();
@@ -792,7 +792,7 @@ public class Function {
}
rq = q.mayUser(trans, trans.user(), rq.value, Access.write);
- if (rq.notOK()) {
+ if (rq.notOK()) {
// Even though not a "writer", Owners still determine who gets to be an Admin
Result<List<UserRoleDAO.Data>> ruinr = q.userRoleDAO().readUserInRole(trans, trans.user(),ns+".owner");
if (!(ruinr.isOKhasData() && ruinr.value.get(0).expires.after(new Date()))) {
@@ -806,7 +806,7 @@ public class Function {
/**
* Helper function that moves permissions from a namespace being deleted to
* its parent namespace
- *
+ *
* @param trans
* @param parent
* @param sb
@@ -827,7 +827,7 @@ public class Function {
}
// Remove old Perm from Roles, save them off
List<RoleDAO.Data> lrdd = new ArrayList<>();
-
+
for (String rl : pdd.roles(false)) {
Result<RoleDAO.Data> rrdd = RoleDAO.Data.decode(trans,q,rl);
if (rrdd.isOKhasData()) {
@@ -838,7 +838,7 @@ public class Function {
trans.error().log(rrdd.errorString());
}
}
-
+
// Save off Old keys
String delP1 = pdd.ns;
NsSplit nss = new NsSplit(parent, pdd.fullType());
@@ -872,7 +872,7 @@ public class Function {
/**
* Helper function that moves roles from a namespace being deleted to its
* parent namespace
- *
+ *
* @param trans
* @param parent
* @param sb
@@ -903,7 +903,7 @@ public class Function {
trans.error().log(rpdd.errorString());
}
}
-
+
// Save off Old keys
String delP1 = rdd.ns;
@@ -938,9 +938,9 @@ public class Function {
/**
* Create Permission (and any missing Permission between this and Parent) if
* we have permission
- *
+ *
* Pass in the desired Management Permission for this Permission
- *
+ *
* If Force is set, then Roles listed will be created, if allowed,
* pre-granted.
*/
@@ -1008,7 +1008,7 @@ public class Function {
Result<PermDAO.Data> pdr = q.permDAO().create(trans, perm);
if (pdr.isOK()) {
return Result.ok();
- } else {
+ } else {
return Result.err(pdr);
}
}
@@ -1118,10 +1118,10 @@ public class Function {
/**
* Only owner of Permission may add to Role
- *
+ *
* If force set, however, Role will be created before Grant, if User is
* allowed to create.
- *
+ *
* @param trans
* @param role
* @param pd
@@ -1129,7 +1129,7 @@ public class Function {
*/
public Result<Void> addPermToRole(AuthzTrans trans, RoleDAO.Data role,PermDAO.Data pd, boolean fromApproval) {
String user = trans.user();
-
+
if (!fromApproval) {
Result<NsDAO.Data> rRoleCo = q.deriveFirstNsForType(trans, role.ns, NsType.COMPANY);
if (rRoleCo.notOK()) {
@@ -1148,14 +1148,14 @@ public class Function {
return Result.err(r);
}
}
-
+
// Must be Perm Admin, or Granted Special Permission
Result<NsDAO.Data> ucp = q.mayUser(trans, user, pd, Access.write);
if (ucp.notOK()) {
// Don't allow CLI potential Grantees to change their own AAF
// Perms,
- if ((ROOT_NS.equals(pd.ns) && Question.NS.equals(pd.type))
+ if ((ROOT_NS.equals(pd.ns) && Question.NS.equals(pd.type))
|| !q.isGranted(trans, trans.user(),ROOT_NS,Question.PERM, rPermCo.value.name, "grant")) {
// Not otherwise granted
// TODO Needed?
@@ -1233,7 +1233,7 @@ public class Function {
/**
* Either Owner of Role or Permission may delete from Role
- *
+ *
* @param trans
* @param role
* @param pd
@@ -1332,10 +1332,10 @@ public class Function {
/**
* Add a User to Role
- *
+ *
* 1) Role must exist 2) User must be a known Credential (i.e. mechID ok if
* Credential) or known Organizational User
- *
+ *
* @param trans
* @param org
* @param urData
@@ -1352,9 +1352,9 @@ public class Function {
rv = checkValidID(trans, new Date(), urData.user);
}
if (rv.notOK()) {
- return rv;
+ return rv;
}
-
+
// Check if record exists
if (q.userRoleDAO().read(trans, urData).isOKhasData()) {
return Result.err(Status.ERR_ConflictAlreadyExists,
@@ -1366,8 +1366,8 @@ public class Function {
}
urData.expires = trans.org().expiration(null, Expiration.UserInRole, urData.user).getTime();
-
-
+
+
Result<UserRoleDAO.Data> udr = q.userRoleDAO().create(trans, urData);
if (udr.status == OK) {
return Result.ok();
@@ -1392,9 +1392,9 @@ public class Function {
/**
* Extend User Role.
- *
+ *
* extend the Expiration data, according to Organization rules.
- *
+ *
* @param trans
* @param org
* @param urData
@@ -1406,7 +1406,7 @@ public class Function {
return Result.err(Status.ERR_UserRoleNotFound,
"User Role does not exist");
}
-
+
if (q.roleDAO().read(trans, urData.ns, urData.rname).notOKorIsEmpty()) {
return Result.err(Status.ERR_RoleNotFound,
"Role [%s.%s] does not exist", urData.ns,urData.rname);
@@ -1485,13 +1485,13 @@ public class Function {
}
}
}
-
+
if (owners.isEmpty()) {
return Result.err(Result.ERR_NotFound,"No Owners found for " + nsd.name);
}
-
+
// Create Future Object
-
+
Result<FutureDAO.Data> fr = q.futureDAO().create(trans, data, id);
if (fr.isOK()) {
sb.append("Created Future: ");
@@ -1518,7 +1518,7 @@ public class Function {
} catch (Exception e) {
return Result.err(e);
}
-
+
return Result.ok(sb.toString());
}
@@ -1528,7 +1528,7 @@ public class Function {
public interface Lookup<T> {
T get(AuthzTrans trans, Object ... keys);
}
-
+
public Lookup<UserRoleDAO.Data> urDBLookup = new Lookup<UserRoleDAO.Data>() {
@Override
public UserRoleDAO.Data get(AuthzTrans trans, Object ... keys) {
@@ -1542,11 +1542,11 @@ public class Function {
};
/**
- * Note: if "allApprovals for Ticket is null, it will be looked up.
+ * Note: if "allApprovals for Ticket is null, it will be looked up.
* if "fdd" is null, it will be looked up, but
- *
+ *
* They can be passed for performance reasons.
- *
+ *
* @param trans
* @param cd
* @param allApprovalsForTicket
@@ -1575,7 +1575,7 @@ public class Function {
return Result.err(Result.ERR_BadData,"Cannot reconstitute %1",curr.memo);
}
}
-
+
boolean aDenial = false;
int cntSuper=0, appSuper=0,cntOwner=0, appOwner=0;
for (ApprovalDAO.Data add : la.get(trans)) {
@@ -1603,7 +1603,7 @@ public class Function {
break;
}
}
-
+
Result<OP_STATUS> ros=null;
if (aDenial) {
ros = OP_STATUS.RD;
@@ -1624,7 +1624,7 @@ public class Function {
}
}
}
-
+
// Decision: If not Denied, and at least owner, if exists, and at least one Super, if exists
boolean goDecision = (cntOwner>0?appOwner>0:true) && (cntSuper>0?appSuper>0:true);
@@ -1720,7 +1720,7 @@ public class Function {
if (fop == FUTURE_OP.C) {
ros = set(OP_STATUS.RE, q.credDAO().dao().create(trans, data));
}
- }
+ }
} catch (Exception e) {
trans.error().log("Exception: ", e.getMessage(),
" \n occurred while performing", curr.memo,
@@ -1732,7 +1732,7 @@ public class Function {
//return Result.err(Status.ACC_Future, "Full Approvals not obtained: No action taken");
ros = OP_STATUS.RP;
}
-
+
return ros;
}
@@ -1745,7 +1745,7 @@ public class Function {
}
}
- private Result<ApprovalDAO.Data> addIdentity(AuthzTrans trans, StringBuilder sb,
+ private Result<ApprovalDAO.Data> addIdentity(AuthzTrans trans, StringBuilder sb,
Boolean[] first, String user, String memo, FUTURE_OP op, Identity u, UUID ticket, String type) throws OrganizationException {
ApprovalDAO.Data ad = new ApprovalDAO.Data();
// Note ad.id is set by ApprovalDAO Create
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/PermLookup.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/PermLookup.java
index 3f0e92e7..5a27e5ec 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/PermLookup.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/PermLookup.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -38,9 +38,9 @@ import org.onap.aaf.auth.env.AuthzTrans;
import org.onap.aaf.auth.layer.Result;
/**
- * PermLookup is a Storage class for the various pieces of looking up Permission
+ * PermLookup is a Storage class for the various pieces of looking up Permission
* during Transactions to avoid duplicate processing
- *
+ *
* @author Jonathan
*
*/
@@ -53,9 +53,9 @@ public class PermLookup {
private Result<List<RoleDAO.Data>> roles = null;
private Result<Set<String>> permNames = null;
private Result<List<PermDAO.Data>> perms = null;
-
+
private PermLookup() {}
-
+
public static PermLookup get(AuthzTrans trans, Question q, String user) {
PermLookup lp=null;
Map<String, PermLookup> permMap = trans.get(Question.PERMS, null);
@@ -74,7 +74,7 @@ public class PermLookup {
}
return lp;
}
-
+
public Result<List<UserRoleDAO.Data>> getUserRoles() {
if (userRoles==null) {
userRoles = q.userRoleDAO().readByUser(trans,user);
@@ -143,7 +143,7 @@ public class PermLookup {
return permNames;
}
}
-
+
public Result<List<PermDAO.Data>> getPerms(boolean lookup) {
if (perms==null) {
// Note: It should be ok for a Valid user to have no permissions -
@@ -156,7 +156,7 @@ public class PermLookup {
Map<String,PermDAO.Data> mspdd = new TreeMap<>();
Result<String[]> ap = PermDAO.Data.decodeToArray(trans, q, perm);
if (ap.isOK()) {
-
+
Result<List<PermDAO.Data>> rlpd = q.permDAO().read(perm,trans,ap.value);
if (rlpd.isOKhasData()) {
for (PermDAO.Data pData : rlpd.value) {
@@ -174,7 +174,7 @@ public class PermLookup {
pdd.description = pData.description;
lpdd.add(pdd);
}
- pdd.roles(true).add(pdr);
+ pdd.roles(true).add(pdr);
break;
}
}
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Question.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Question.java
index c7ee5938..1809686a 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Question.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Question.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -81,9 +81,9 @@ import com.datastax.driver.core.Cluster;
/**
* Question HL DAO
- *
+ *
* A Data Access Combination Object which asks Security and other Questions
- *
+ *
* @author Jonathan
*
*/
@@ -135,57 +135,57 @@ public class Question {
public HistoryDAO historyDAO() {
return historyDAO;
}
-
+
private final CachedNSDAO nsDAO;
public CachedNSDAO nsDAO() {
return nsDAO;
}
-
+
private final CachedRoleDAO roleDAO;
public CachedRoleDAO roleDAO() {
return roleDAO;
}
-
+
private final CachedPermDAO permDAO;
public CachedPermDAO permDAO() {
return permDAO;
}
-
+
private final CachedUserRoleDAO userRoleDAO;
public CachedUserRoleDAO userRoleDAO() {
return userRoleDAO;
}
-
+
private final CachedCredDAO credDAO;
public CachedCredDAO credDAO() {
return credDAO;
}
-
+
private final CachedCertDAO certDAO;
public CachedCertDAO certDAO() {
return certDAO;
}
-
+
private final DelegateDAO delegateDAO;
public DelegateDAO delegateDAO() {
return delegateDAO;
}
-
+
private final FutureDAO futureDAO;
public FutureDAO futureDAO() {
return futureDAO;
}
-
+
private final ApprovalDAO approvalDAO;
public ApprovalDAO approvalDAO() {
return approvalDAO;
}
-
+
public final LocateDAO locateDAO;
public LocateDAO locateDAO() {
return locateDAO;
}
-
+
private final CacheInfoDAO cacheInfoDAO;
private final int cldays;
private final boolean alwaysSpecial;
@@ -216,18 +216,18 @@ public class Question {
if (specialLogSlot==null) {
specialLogSlot = trans.slot(AuthzTransFilter.SPECIAL_LOG_SLOT);
}
-
+
if (transIDSlot==null) {
transIDSlot = trans.slot(AuthzTransFilter.TRANS_ID_SLOT);
}
-
+
AbsCassDAO.primePSIs(trans);
-
+
cldays = Integer.parseInt(trans.getProperty(Config.AAF_CRED_WARN_DAYS, Config.AAF_CRED_WARN_DAYS_DFT));
-
+
alwaysSpecial = Boolean.parseBoolean(trans.getProperty("aaf_always_special", Boolean.FALSE.toString()));
}
-
+
/**
* Note: This Constructor created for JUNIT Purposes. Do not use otherwise.
*/
@@ -259,7 +259,7 @@ public class Question {
CachedDAO.startCleansing(env, credDAO, userRoleDAO);
CachedDAO.startRefresh(env, cacheInfoDAO);
}
-
+
public void close(AuthzTrans trans) {
historyDAO.close(trans);
cacheInfoDAO.close(trans);
@@ -283,7 +283,7 @@ public class Question {
pdd.type = type.substring(colon+1);
pdd.instance = instance;
pdd.action = action;
-
+
return Result.ok(pdd);
} else {
return Result.err(Result.ERR_BadData,"Could not extract ns and type from " + type);
@@ -301,10 +301,10 @@ public class Question {
/**
* getPermsByUser
- *
+ *
* Because this call is frequently called internally, AND because we already
* look for it in the initial Call, we cache within the Transaction
- *
+ *
* @param trans
* @param user
* @return
@@ -312,26 +312,26 @@ public class Question {
public Result<List<PermDAO.Data>> getPermsByUser(AuthzTrans trans, String user, boolean lookup) {
return PermLookup.get(trans, this, user).getPerms(lookup);
}
-
+
public Result<List<PermDAO.Data>> getPermsByUserFromRolesFilter(AuthzTrans trans, String user, String forUser) {
PermLookup plUser = PermLookup.get(trans, this, user);
Result<Set<String>> plPermNames = plUser.getPermNames();
if (plPermNames.notOK()) {
return Result.err(plPermNames);
}
-
+
Set<String> nss;
if (forUser.equals(user)) {
nss = null;
} else {
- // Setup a TreeSet to check on Namespaces to
+ // Setup a TreeSet to check on Namespaces to
nss = new TreeSet<>();
PermLookup fUser = PermLookup.get(trans, this, forUser);
Result<Set<String>> forUpn = fUser.getPermNames();
if (forUpn.notOK()) {
return Result.err(forUpn);
}
-
+
for (String pn : forUpn.value) {
Result<String[]> decoded = PermDAO.Data.decodeToArray(trans, this, pn);
if (decoded.isOKhasData()) {
@@ -356,7 +356,7 @@ public class Question {
trans.error().log(pn,", derived from a Role, is invalid. Run Data Cleanup:",rpdd.errorString());
}
}
- return Result.ok(rlpUser);
+ return Result.ok(rlpUser);
}
public Result<List<PermDAO.Data>> getPermsByType(AuthzTrans trans, String type) {
@@ -389,7 +389,7 @@ public class Question {
if (nss.notOK()) {
return Result.err(nss);
}
-
+
return permDAO.read(trans, nss.value.ns, nss.value.name, instance,action);
}
}
@@ -462,22 +462,22 @@ public class Question {
/**
* Derive NS
- *
+ *
* Given a Child Namespace, figure out what the best Namespace parent is.
- *
+ *
* For instance, if in the NS table, the parent "org.osaaf" exists, but not
* "org.osaaf.child" or "org.osaaf.a.b.c", then passing in either
* "org.osaaf.child" or "org.osaaf.a.b.c" will return "org.osaaf"
- *
+ *
* Uses recursive search on Cached DAO data
- *
+ *
* @param trans
* @param child
* @return
*/
public Result<NsDAO.Data> deriveNs(AuthzTrans trans, String child) {
Result<List<NsDAO.Data>> r = nsDAO.read(trans, child);
-
+
if (r.isOKhasData()) {
return Result.ok(r.value.get(0));
} else {
@@ -502,7 +502,7 @@ public class Question {
return Result.ok(nsd);
} else {
int dot = str.lastIndexOf('.');
-
+
if (dot < 0) {
return Result.err(Status.ERR_NsNotFound, "No Namespace for [%s]", str);
} else {
@@ -511,7 +511,7 @@ public class Question {
}
} else {
int dot = str.lastIndexOf('.');
-
+
if (dot < 0) {
return Result.err(Status.ERR_NsNotFound,"There is no valid Company Namespace for %s",str);
} else {
@@ -539,9 +539,9 @@ public class Question {
/**
* Translate an ID into it's domain
- *
+ *
* i.e. myid1234@aaf.att.com results in domain of com.att.aaf
- *
+ *
* @param id
* @return
*/
@@ -568,9 +568,9 @@ public class Question {
/**
* Validate Namespace of ID@Domain
- *
+ *
* Namespace is reverse order of Domain.
- *
+ *
* @param trans
* @param id
* @return
@@ -584,7 +584,7 @@ public class Question {
ns = domain2ns(id);
}
if (ns.length() > 0) {
- if (!trans.org().getDomain().equals(ns)) {
+ if (!trans.org().getDomain().equals(ns)) {
Result<List<NsDAO.Data>> rlnsd = nsDAO.read(trans, ns);
if (rlnsd.isOKhasData()) {
return Result.ok(rlnsd.value.get(0));
@@ -611,7 +611,7 @@ public class Question {
ns = ns.substring(0, last);
}
} while (last >= 0);
-
+
// SAFETY - Do not allow these when NS is Root
if(!isRoot) {
// com.att.aaf.ns|:<client ns>:ns|<access>
@@ -681,7 +681,7 @@ public class Question {
// Check if Access to Whole NS
// AAF-724 - Make consistent response for May User", and not take the
// last check... too confusing.
- Result<org.onap.aaf.auth.dao.cass.NsDAO.Data> rv = mayUserVirtueOfNS(trans, user, ndd,
+ Result<org.onap.aaf.auth.dao.cass.NsDAO.Data> rv = mayUserVirtueOfNS(trans, user, ndd,
":" + rdd.ns + ":ns", access.name());
if (rv.isOK()) {
return rv;
@@ -717,7 +717,7 @@ public class Question {
if (isGranted(trans, user, pdd.ns, pdd.type, pdd.instance, pdd.action)) {
return Result.ok(ndd);
}
-
+
String permInst = ":perm:" + pdd.type + ':' + pdd.instance + ':' + pdd.action;
// <ns>.access|:role:<role name>|<read|write>
String ns = ndd.name;
@@ -795,7 +795,7 @@ public class Question {
break;
case read:
case write:
- if (!isUser && !isDelegate &&
+ if (!isUser && !isDelegate &&
!isGranted(trans, trans.user(), ROOT_NS,DELG,org.getDomain(), access.name())) {
return Result.err(Status.ERR_Denied,
"[%s] may not %s delegates for [%s]", trans.user(),
@@ -818,14 +818,14 @@ public class Question {
String ns = nsd.name;
// If an ADMIN of the Namespace, then allow
-
+
Result<List<UserRoleDAO.Data>> rurd;
if ((rurd = userRoleDAO.readUserInRole(trans, user, ns+DOT_ADMIN)).isOKhasData()) {
return Result.ok(nsd);
} else if (rurd.status==Result.ERR_Backend) {
return Result.err(rurd);
}
-
+
// If Specially granted Global Permission
if (isGranted(trans, user, ROOT_NS,NS, ns_and_type, access)) {
return Result.ok(nsd);
@@ -851,13 +851,13 @@ public class Question {
ns_and_type);
}
-
+
/**
* isGranted
- *
+ *
* Important function - Check internal Permission Schemes for Permission to
* do things
- *
+ *
* @param trans
* @param type
* @param instance
@@ -871,7 +871,7 @@ public class Question {
if (ns.equals(pd.ns)) {
if (type.equals(pd.type)) {
if (PermEval.evalInstance(pd.instance, instance)) {
- if (PermEval.evalAction(pd.action, action)) { // don't return action here, might miss other action
+ if (PermEval.evalAction(pd.action, action)) { // don't return action here, might miss other action
return true;
}
}
@@ -900,32 +900,32 @@ public class Question {
}
} else {
Date now = new Date();
- // Bug noticed 6/22. Sorting on the result can cause Concurrency Issues.
+ // Bug noticed 6/22. Sorting on the result can cause Concurrency Issues.
// 9/14/2019. Use TreeSet for sorting, and using only the LAST of a Tagged entry
Collection<CredDAO.Data> cddl;
if (result.value.size() > 1) {
- Map<String,CredDAO.Data> mcdd = new TreeMap<>();
- CredDAO.Data cdd;
- String tag;
- int pseudoTag = 0;
+ Map<String,CredDAO.Data> mcdd = new TreeMap<>();
+ CredDAO.Data cdd;
+ String tag;
+ int pseudoTag = 0;
for (CredDAO.Data rcdd : result.value) {
if (rcdd.type==CredDAO.BASIC_AUTH || rcdd.type==CredDAO.BASIC_AUTH_SHA256) {
- if(rcdd.tag==null) {
- mcdd.put(Integer.toString(++pseudoTag),rcdd);
- } else {
- tag = rcdd.tag;
- cdd = mcdd.get(tag);
- if(cdd==null || cdd.expires.before(rcdd.expires)) {
- mcdd.put(tag,rcdd);
- }
- }
+ if(rcdd.tag==null) {
+ mcdd.put(Integer.toString(++pseudoTag),rcdd);
+ } else {
+ tag = rcdd.tag;
+ cdd = mcdd.get(tag);
+ if(cdd==null || cdd.expires.before(rcdd.expires)) {
+ mcdd.put(tag,rcdd);
+ }
+ }
}
}
cddl = mcdd.values();
} else {
cddl = result.value;
}
-
+
Date expired = null;
StringBuilder debug = willSpecialLog(trans,user)?new StringBuilder():null;
for (CredDAO.Data cdd : cddl) {
@@ -934,7 +934,7 @@ public class Question {
}
if (cdd.expires.after(now)) {
byte[] dbcred = cdd.cred.array();
-
+
try {
switch(cdd.type) {
case CredDAO.BASIC_AUTH:
@@ -952,7 +952,7 @@ public class Question {
bb.putInt(cdd.other);
bb.put(cred);
byte[] hash = Hash.hashSHA256(bb.array());
-
+
if (Hash.compareTo(hash,dbcred)==0) {
checkLessThanDays(trans,cldays,now,cdd);
trans.setTag(cdd.tag);
@@ -974,7 +974,7 @@ public class Question {
}
}
} // end for each
-
+
if (expired!=null) {
// Note: this is only returned if there are no good Credentials
rv = Result.err(Status.ERR_Security,
@@ -1015,7 +1015,7 @@ public class Question {
if (cexp<close) {
int daysLeft = days-(int)((close-cexp)/86400000);
trans.audit().printf("user=%s,ip=%s,expires=%s,days=%d,tag=%s,msg=\"Password expires in less than %d day%s\"",
- cdd.id,trans.ip(),Chrono.dateOnlyStamp(cdd.expires),daysLeft, cdd.tag,
+ cdd.id,trans.ip(),Chrono.dateOnlyStamp(cdd.expires),daysLeft, cdd.tag,
daysLeft,daysLeft==1?"":"s");
}
}
@@ -1038,14 +1038,14 @@ public class Question {
} finally {
tt.done();
}
-
+
} else if (cred.type==CredDAO.FQI) {
cred.cred = null;
return Result.ok(cred);
}
return Result.err(Status.ERR_Security,"invalid/unreadable credential");
}
-
+
public Result<Boolean> userCredCheck(AuthzTrans trans, CredDAO.Data orig, final byte[] raw) {
Result<Boolean> rv;
TimeTaken tt = trans.start("CheckCred Cred", Env.SUB);
@@ -1205,7 +1205,7 @@ public class Question {
}
return b;
}
-
+
public static void logEncryptTrace(AuthzTrans trans, String data) {
long ti;
trans.put(transIDSlot, ti=nextTraceID());
@@ -1222,7 +1222,7 @@ public class Question {
}
boolean rc = specialLog.add(id);
if (rc) {
- trans.trace().printf("Trace on for %s requested by %s",id,trans.user());
+ trans.trace().printf("Trace on for %s requested by %s",id,trans.user());
}
return rc;
}
@@ -1236,12 +1236,12 @@ public class Question {
specialLog = null;
}
if (rv) {
- trans.trace().printf("Trace off for %s requested by %s",id,trans.user());
+ trans.trace().printf("Trace off for %s requested by %s",id,trans.user());
}
return rv;
}
- /**
+ /**
* canMove
* Which Types can be moved
* @param nsType
@@ -1274,7 +1274,7 @@ public class Question {
};
return false;
}
-
+
public boolean isOwner(AuthzTrans trans, String user, String ns) {
Result<List<UserRoleDAO.Data>> rur = userRoleDAO().read(trans, user,ns+DOT_OWNER);
if (rur.isOKhasData()) {for (UserRoleDAO.Data urdd : rur.value){
@@ -1297,14 +1297,14 @@ public class Question {
}};
return count;
}
-
+
/**
* Return a Unique String, (same string, if it is already unique), with only
* lowercase letters, digits and the '.' character.
- *
+ *
* @param name
* @return
- * @throws IOException
+ * @throws IOException
*/
public static String toUnique(String name) throws IOException {
byte[] from = name.getBytes();
@@ -1317,7 +1317,7 @@ public class Question {
}
return sb.toString();
}
-
+
public static String fromUnique(String name) throws IOException {
byte[] from = name.getBytes();
StringBuilder sb = new StringBuilder();
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFLocator.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFLocator.java
index bd297e7d..f8362553 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFLocator.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFLocator.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -50,18 +50,18 @@ public class DirectAAFLocator extends AbsAAFLocator<AuthzTrans> {
private final URI uri;
/**
- *
+ *
* @param env
* @param ldao
* @param key must be one or more of service, version, other in that order
- * @throws LocatorException
+ * @throws LocatorException
*/
public DirectAAFLocator(AuthzEnv env, LocateDAO ldao, String name, String version) throws LocatorException {
- super(env.access(), name, 1000L /* Don't hit DB more than once a second */);
+ super(env.access(), name, 1000L /* Don't hit DB more than once a second */);
this.env = env;
this.ldao = ldao;
if (version!=null) {
- try {
+ try {
String[] v = Split.split('.',version);
if (v.length>0) {major = Integer.parseInt(v[0]);}
if (v.length>1) {minor = Integer.parseInt(v[1]);}
@@ -71,7 +71,7 @@ public class DirectAAFLocator extends AbsAAFLocator<AuthzTrans> {
throw new LocatorException("Invalid Version String: " + version);
}
}
-
+
try {
String aaf_url;
if(name.indexOf('.')>=0) {
@@ -87,10 +87,10 @@ public class DirectAAFLocator extends AbsAAFLocator<AuthzTrans> {
throw new LocatorException(e);
}
myhostname=null;
- myport = 0;
+ myport = 0;
}
-
-
+
+
@Override
public boolean refresh() {
AuthzTrans trans = env.newTransNoAvg();
@@ -119,7 +119,7 @@ public class DirectAAFLocator extends AbsAAFLocator<AuthzTrans> {
for (String s : d.subprotocol(false)) {
endpoint.getSubprotocol().add(s);
}
-
+
try {
epl.add(new EP(endpoint,latitude,longitude));
} catch (URISyntaxException e) {
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFLur.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFLur.java
index 59613961..2ccbd236 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFLur.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFLur.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -44,7 +44,7 @@ import org.onap.aaf.misc.env.util.Split;
public class DirectAAFLur implements Lur {
private final AuthzEnv env;
private final Question question;
-
+
public DirectAAFLur(AuthzEnv env, Question question/*, TokenMgr tm*/) {
this.env = env;
this.question = question;
@@ -55,7 +55,7 @@ public class DirectAAFLur implements Lur {
public boolean fish(Principal bait, Permission ... pond) {
return fish(env.newTransNoAvg(),bait,pond);
}
-
+
public boolean fish(AuthzTrans trans, Principal bait, Permission ... pond) {
boolean rv = false;
Result<List<Data>> pdr = question.getPermsByUser(trans, bait.getName(),false);
@@ -94,7 +94,7 @@ public class DirectAAFLur implements Lur {
env.error().log("Can't access Cassandra to fulfill Permission Query: ",pdr.status,"-", pdr.details);
}
}
-
+
@Override
public void destroy() {
}
@@ -103,7 +103,7 @@ public class DirectAAFLur implements Lur {
public boolean handlesExclusively(Permission ... pond) {
return false;
}
-
+
/**
* Small Class implementing CADI's Permission with Cassandra Data
* @author Jonathan
@@ -111,15 +111,15 @@ public class DirectAAFLur implements Lur {
*/
public static class PermPermission implements Permission {
private PermDAO.Data data;
-
+
public PermPermission(PermDAO.Data d) {
data = d;
}
-
+
public PermPermission(AuthzTrans trans, Question q, String p) {
data = PermDAO.Data.create(trans, q, p);
}
-
+
public PermPermission(String ns, String type, String instance, String action) {
data = new PermDAO.Data();
data.ns = ns;
@@ -161,12 +161,12 @@ public class DirectAAFLur implements Lur {
public String permType() {
return "AAFLUR";
}
-
+
}
-
+
public String toString() {
return "DirectAAFLur is enabled";
-
+
}
/* (non-Javadoc)
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFUserPass.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFUserPass.java
index bdeb77f3..f5b7779b 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFUserPass.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFUserPass.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -37,14 +37,14 @@ import org.onap.aaf.cadi.CredVal;
/**
* DirectAAFUserPass is intended to provide password Validation directly from Cassandra Database, and is only
* intended for use in AAF itself. The normal "AAF Taf" objects are, of course, clients.
- *
+ *
* @author Jonathan
*
*/
public class DirectAAFUserPass implements CredVal {
private final AuthzEnv env;
private final Question question;
-
+
public DirectAAFUserPass(AuthzEnv env, Question question) {
this.env = env;
this.question = question;
@@ -55,7 +55,7 @@ public class DirectAAFUserPass implements CredVal {
if(user==null || type==null || pass==null) {
return false;
}
-
+
try {
AuthzTrans trans;
boolean transfer = false;
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectCertIdentity.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectCertIdentity.java
index f3351dae..d78ddcaa 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectCertIdentity.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectCertIdentity.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -40,10 +40,10 @@ import org.onap.aaf.cadi.taf.cert.X509Taf;
/**
* Direct view of CertIdentities
- *
- * Warning: this class is difficult to instantiate. The only service that can use it is AAF itself, and is thus
+ *
+ * Warning: this class is difficult to instantiate. The only service that can use it is AAF itself, and is thus
* entered in the "init" after the CachedCertDAO is created.
- *
+ *
* @author Jonathan
*
*/
@@ -62,7 +62,7 @@ public class DirectCertIdentity implements CertIdentity {
byte[] fingerprint = X509Taf.getFingerPrint(certBytes);
AuthzTrans trans = (AuthzTrans) req.getAttribute(TransFilter.TRANS_TAG);
-
+
Result<List<Data>> cresp = certDAO.read(trans, ByteBuffer.wrap(fingerprint));
if (cresp.isOKhasData()) {
Data cdata = cresp.value.get(0);
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectLocatorCreator.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectLocatorCreator.java
index aa6bf8c5..2ea6830c 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectLocatorCreator.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectLocatorCreator.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,12 +31,12 @@ public class DirectLocatorCreator implements AbsAAFLocator.LocatorCreator {
private final LocateDAO locateDAO;
private String myhostname;
private int myport;
-
+
public DirectLocatorCreator(AuthzEnv env, LocateDAO locateDAO) {
this.env = env;
this.locateDAO = locateDAO;
}
-
+
@Override
public AbsAAFLocator<?> create(String key, String version) throws LocatorException {
DirectAAFLocator dal = new DirectAAFLocator(env,locateDAO,key,version);
@@ -45,7 +45,7 @@ public class DirectLocatorCreator implements AbsAAFLocator.LocatorCreator {
}
return dal;
}
-
+
/**
* Make sure DirectAAFLocator created does not include self.
* @param hostname
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectRegistrar.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectRegistrar.java
index ce9d5930..75830863 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectRegistrar.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectRegistrar.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -39,7 +39,7 @@ import locate.v1_0.MgmtEndpoints;
public class DirectRegistrar implements Registrant<AuthzEnv> {
private LocateDAO ldao;
- private List<LocateDAO.Data> ldd;
+ private List<LocateDAO.Data> ldd;
public DirectRegistrar(Access access, LocateDAO ldao, int port) throws CadiException {
this.ldao = ldao;
ldd = new ArrayList<>();
@@ -70,7 +70,7 @@ public class DirectRegistrar implements Registrant<AuthzEnv> {
@Override
public Result<Void> update(AuthzEnv env) {
- AuthzTrans trans = env.newTransNoAvg();
+ AuthzTrans trans = env.newTransNoAvg();
StringBuilder sb = null;
for(LocateDAO.Data ld : ldd) {
org.onap.aaf.auth.layer.Result<Void> dr = ldao.update(trans, ld);
@@ -83,7 +83,7 @@ public class DirectRegistrar implements Registrant<AuthzEnv> {
}
}
}
-
+
if(sb==null) {
return Result.ok(200, null);
} else {
@@ -96,7 +96,7 @@ public class DirectRegistrar implements Registrant<AuthzEnv> {
*/
@Override
public Result<Void> cancel(AuthzEnv env) {
- AuthzTrans trans = env.newTransNoAvg();
+ AuthzTrans trans = env.newTransNoAvg();
StringBuilder sb = null;
for(LocateDAO.Data ld : ldd) {
org.onap.aaf.auth.layer.Result<Void> dr = ldao.delete(trans, ld, false);
@@ -109,7 +109,7 @@ public class DirectRegistrar implements Registrant<AuthzEnv> {
}
}
}
-
+
if(sb==null) {
return Result.ok(200, null);
} else {
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_Cached.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_Cached.java
index 055e91ed..f6bdf20a 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_Cached.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_Cached.java
@@ -7,9 +7,9 @@
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
- * *
+ * *
* * http://www.apache.org/licenses/LICENSE-2.0
- * *
+ * *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -59,20 +59,20 @@ public class JU_Cached {
@Mock
CIDAO<AuthzTrans> cidaoATMock;
-
+
String name = "nameString";
@Before
public void setUp(){
MockitoAnnotations.initMocks(this);
}
-
+
@Test
public void testCachedIdx(){
Cached<Trans, DataStub> cached = new Cached<Trans, DataStub>(ciDaoMock, name, 1, 30000L);
assertThat(cached.cacheIdx("1234567890"), is(0));
}
-
+
@Test
public void testInvalidate(){
Cached<Trans, DataStub> cached = new Cached<Trans, DataStub>(ciDaoMock, name, 5, 30000L);
@@ -103,26 +103,26 @@ public class JU_Cached {
// Trans transMock;
// @Mock
// Getter<DAO> getterMock;
-//
+//
// @Test
// public void testGet(){
// cached.get(transMock, name, getterMock);
// fail("not implemented");
// }
-//
+//
// @SuppressWarnings("unchecked")
// public Result<List<DATA>> get(TRANS trans, String key, Getter<DATA> getter) {
// List<DATA> ld = null;
// Result<List<DATA>> rld = null;
-//
+//
// int cacheIdx = cacheIdx(key);
// Map<String, Dated> map = ((Map<String,Dated>)cache[cacheIdx]);
-//
+//
// // Check for saved element in cache
// Dated cached = map.get(key);
// // Note: These Segment Timestamps are kept up to date with DB
// Date dbStamp = info.get(trans, name,cacheIdx);
-//
+//
// // Check for cache Entry and whether it is still good (a good Cache Entry is same or after DBEntry, so we use "before" syntax)
// if (cached!=null && dbStamp.before(cached.timestamp)) {
// ld = (List<DATA>)cached.data;
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CachedDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CachedDAO.java
index 242904ac..23deced0 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CachedDAO.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CachedDAO.java
@@ -7,9 +7,9 @@
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
- * *
+ * *
* * http://www.apache.org/licenses/LICENSE-2.0
- * *
+ * *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -44,22 +44,22 @@ public class JU_CachedDAO {
@Mock
DAO daoMock;
@Mock
- CIDAO<Trans> ciDAOMock;
+ CIDAO<Trans> ciDAOMock;
int segsize=1;
Object[ ] objs = new Object[2];
-
+
@Before
public void setUp(){
objs[0] = "helo";
objs[1] = "polo";
cachedDAO = new CachedDAO(daoMock, ciDAOMock, segsize, segsize);
}
-
+
@Test
public void testKeyFromObjs(){
String result = cachedDAO.keyFromObjs(objs);
System.out.println("value of resut " +result);
assertTrue(true);
}
-
+
}
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CassAccess.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CassAccess.java
index c06cd5c1..3f6b1500 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CassAccess.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CassAccess.java
@@ -7,9 +7,9 @@
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
- * *
+ * *
* * http://www.apache.org/licenses/LICENSE-2.0
- * *
+ * *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -43,7 +43,7 @@ import com.datastax.driver.core.Cluster.Builder;
@RunWith(PowerMockRunner.class)
public class JU_CassAccess {
CassAccess cassAccess;
-
+
public static final String KEYSPACE = "authz";
public static final String CASSANDRA_CLUSTERS = "cassandra.clusters";
public static final String CASSANDRA_CLUSTERS_PORT = "cassandra.clusters.port";
@@ -58,7 +58,7 @@ public class JU_CassAccess {
@Mock
Env envMock;
String prefix=null;
-
+
@Before
public void setUp(){
cassAccess = new CassAccess();
@@ -68,7 +68,7 @@ public class JU_CassAccess {
// @Test(expected=APIException.class)
// public void testCluster() throws APIException, IOException {
//// cassAccess.cluster(envMock, prefix);
-//
+//
// }
}
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CassDAOImpl.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CassDAOImpl.java
index 2e03c060..9eab56ff 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CassDAOImpl.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_CassDAOImpl.java
@@ -7,9 +7,9 @@
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
- * *
+ * *
* * http://www.apache.org/licenses/LICENSE-2.0
- * *
+ * *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -76,7 +76,7 @@ AuthzTrans authzTransMock;
}
//TODO: Gabe [JUnit] Visibility issue
- @Test
+ @Test
public void testReadConsistency() {
String table = "users";
PowerMockito.when(authzTransMock.getProperty(CASS_READ_CONSISTENCY+'.'+table)).thenReturn("TWO");
@@ -84,8 +84,8 @@ AuthzTrans authzTransMock;
System.out.println("Consistency level" + consistencyLevel.name());
assertEquals("TWO", consistencyLevel.name());
}
-
- @Test
+
+ @Test
public void testWriteConsistency() {
String table = "users";
PowerMockito.when(authzTransMock.getProperty(CASS_WRITE_CONSISTENCY+'.'+table)).thenReturn(null);
@@ -93,5 +93,5 @@ AuthzTrans authzTransMock;
System.out.println("Consistency level" + consistencyLevel.name());
assertEquals("ONE", consistencyLevel.name());
}
-
+
}
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_DAOException.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_DAOException.java
index c1592bdb..f8a09c60 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_DAOException.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/JU_DAOException.java
@@ -7,9 +7,9 @@
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
- * *
+ * *
* * http://www.apache.org/licenses/LICENSE-2.0
- * *
+ * *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -35,32 +35,32 @@ public class JU_DAOException {
DAOException daoException;
String message = "message";
- Throwable cause;
+ Throwable cause;
@Before
public void setUp(){
- daoException = new DAOException();
+ daoException = new DAOException();
}
@Test
public void testNoArgConstructor(){
assertNull(daoException.getMessage());
}
-
+
@Test
public void testOneArgConstructorMsg(){
- daoException = new DAOException("test message");
+ daoException = new DAOException("test message");
assertTrue("test message".equalsIgnoreCase(daoException.getMessage()));
}
-
+
@Test
public void testOneArgConstructorThrowable(){
- daoException = new DAOException(new Throwable());
+ daoException = new DAOException(new Throwable());
assertTrue("java.lang.Throwable".equalsIgnoreCase(daoException.getMessage()));
}
-
+
@Test
public void testTwoArgConstructor(){
- daoException = new DAOException("test message", new Throwable());
+ daoException = new DAOException("test message", new Throwable());
assertTrue("test message".equalsIgnoreCase(daoException.getMessage()));
}
}
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/AbsJUCass.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/AbsJUCass.java
index bb0fcd43..7780a165 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/AbsJUCass.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/AbsJUCass.java
@@ -7,9 +7,9 @@
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
- * *
+ * *
* * http://www.apache.org/licenses/LICENSE-2.0
- * *
+ * *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -50,7 +50,7 @@ import junit.framework.Assert;
/**
* Do Setup of Cassandra for Cassandra JUnit Testing
- *
+ *
*
*/
public class AbsJUCass {
@@ -63,8 +63,8 @@ public class AbsJUCass {
protected static float json = 0.0f;
protected static AuthzTrans trans;
protected static boolean details = true;
-
- @BeforeClass
+
+ @BeforeClass
public static void startup() throws APIException, IOException {
synchronized(AUTHZ) {
if (env==null) {
@@ -101,14 +101,14 @@ public class AbsJUCass {
Assert.fail("Not able to connect to DB: " + e.getLocalizedMessage());
}
env.info().log("Connected");
-
+
// Load special data here
-
-
+
+
iterations = 0;
-
+
}
-
+
@AfterClass
public static void shutdown() {
if (cluster!=null) {
@@ -120,10 +120,10 @@ public class AbsJUCass {
@Before
public void newTrans() {
trans = env.newTrans();
-
+
trans.setProperty(CassDAOImpl.USER_NAME, System.getProperty("user.name"));
}
-
+
@After
public void auditTrail() {
if (totals==0) { // "updateTotals()" was not called... just do one Trans
@@ -144,7 +144,7 @@ public class AbsJUCass {
}
}
}
-
+
protected void updateTotals() {
Metric metric = trans.auditTrail(0, null, Env.JSON, Env.REMOTE);
totals+=metric.total;
@@ -163,7 +163,7 @@ public class AbsJUCass {
}
env.info().log(
"Total time:",
- totals,
+ totals,
"JSON time:",
json,
"REMOTE time:",
@@ -174,10 +174,10 @@ public class AbsJUCass {
transTime
);
}
-
+
/**
* Take a User/Pass and turn into an MD5 Hashed BasicAuth
- *
+ *
* @param user
* @param pass
* @return
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_Bytification.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_Bytification.java
index 7e460899..2ef15ff3 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_Bytification.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_Bytification.java
@@ -7,9 +7,9 @@
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
- * *
+ * *
* * http://www.apache.org/licenses/LICENSE-2.0
- * *
+ * *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -41,25 +41,25 @@ public class JU_Bytification {
@Test
public void testNS() throws IOException {
-
+
// Normal
NsDAO.Data ns = new NsDAO.Data();
ns.name = "org.osaaf.<pass>";
ns.type = NsType.APP.type;
ByteBuffer bb = ns.bytify();
-
+
NsDAO.Data nsr = new NsDAO.Data();
nsr.reconstitute(bb);
check(ns,nsr);
-
+
// Empty admin
// ns.admin(true).clear();
bb = ns.bytify();
nsr = new NsDAO.Data();
nsr.reconstitute(bb);
check(ns,nsr);
-
+
// Empty responsible
// ns.responsible(true).clear();
bb = ns.bytify();
@@ -72,16 +72,16 @@ public class JU_Bytification {
nsr.reconstitute(bb);
check(ns,nsr);
}
-
+
private void check(NsDAO.Data a, NsDAO.Data b) {
assertEquals(a.name,b.name);
assertEquals(a.type,b.type);
// assertEquals(a.admin.size(),b.admin.size());
-
+
// for (String s: a.admin) {
// assertTrue(b.admin.contains(s));
// }
-//
+//
// assertEquals(a.responsible.size(),b.responsible.size());
// for (String s: a.responsible) {
// assertTrue(b.responsible.contains(s));
@@ -101,7 +101,7 @@ public class JU_Bytification {
RoleDAO.Data rd2 = new RoleDAO.Data();
rd2.reconstitute(bb);
check(rd1,rd2);
-
+
// Overshoot Buffer
StringBuilder sb = new StringBuilder(300);
sb.append("role|instance|veryLongAction...");
@@ -113,15 +113,15 @@ public class JU_Bytification {
rd2 = new RoleDAO.Data();
rd2.reconstitute(bb);
check(rd1,rd2);
-
+
// No Perms
rd1.perms.clear();
-
+
bb = rd1.bytify();
rd2 = new RoleDAO.Data();
rd2.reconstitute(bb);
check(rd1,rd2);
-
+
// 1000 Perms
for (int i=0;i<1000;++i) {
rd1.perms(true).add("com|inst|action"+ i);
@@ -133,11 +133,11 @@ public class JU_Bytification {
check(rd1,rd2);
}
-
+
private void check(RoleDAO.Data a, RoleDAO.Data b) {
assertEquals(a.ns,b.ns);
assertEquals(a.name,b.name);
-
+
assertEquals(a.perms.size(),b.perms.size());
for (String s: a.perms) {
assertTrue(b.perms.contains(s));
@@ -159,15 +159,15 @@ public class JU_Bytification {
PermDAO.Data rd2 = new PermDAO.Data();
rd2.reconstitute(bb);
check(pd1,rd2);
-
+
// No Perms
pd1.roles.clear();
-
+
bb = pd1.bytify();
rd2 = new PermDAO.Data();
rd2.reconstitute(bb);
check(pd1,rd2);
-
+
// 1000 Perms
for (int i=0;i<1000;++i) {
pd1.roles(true).add("org.osaaf.<pass>.my.Role"+ i);
@@ -179,13 +179,13 @@ public class JU_Bytification {
check(pd1,rd2);
}
-
+
private void check(PermDAO.Data a, PermDAO.Data b) {
assertEquals(a.ns,b.ns);
assertEquals(a.type,b.type);
assertEquals(a.instance,b.instance);
assertEquals(a.action,b.action);
-
+
assertEquals(a.roles.size(),b.roles.size());
for (String s: a.roles) {
assertTrue(b.roles.contains(s));
@@ -204,11 +204,11 @@ public class JU_Bytification {
UserRoleDAO.Data urd2 = new UserRoleDAO.Data();
urd2.reconstitute(bb);
check(urd1,urd2);
-
+
// A null
- urd1.expires = null;
+ urd1.expires = null;
urd1.role = null;
-
+
bb = urd1.bytify();
urd2 = new UserRoleDAO.Data();
urd2.reconstitute(bb);
@@ -221,7 +221,7 @@ public class JU_Bytification {
assertEquals(a.expires,b.expires);
}
-
+
@Test
public void testCred() throws IOException {
CredDAO.Data cd = new CredDAO.Data();
@@ -236,11 +236,11 @@ public class JU_Bytification {
CredDAO.Data cd2 = new CredDAO.Data();
cd2.reconstitute(bb);
check(cd,cd2);
-
+
// nulls
cd.expires = null;
cd.cred = null;
-
+
bb = cd.bytify();
cd2 = new CredDAO.Data();
cd2.reconstitute(bb);
@@ -253,7 +253,7 @@ public class JU_Bytification {
assertEquals(a.ns,b.ns);
assertEquals(a.type,b.type);
if (a.cred==null) {
- assertEquals(a.cred,b.cred);
+ assertEquals(a.cred,b.cred);
} else {
int l = a.cred.limit();
assertEquals(l,b.cred.limit());
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_NsType.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_NsType.java
index 05195eeb..bd07e594 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_NsType.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/aaf/test/JU_NsType.java
@@ -7,9 +7,9 @@
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
- * *
+ * *
* * http://www.apache.org/licenses/LICENSE-2.0
- * *
+ * *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -41,15 +41,15 @@ public class JU_NsType {
for (String s : tests) {
nt = NsType.valueOf(s);
assertEquals(s,nt.name());
-
+
nt2 = NsType.fromString(s);
assertEquals(nt,nt2);
-
+
int t = nt.type;
nt2 = NsType.fromType(t);
assertEquals(nt,nt2);
}
-
+
nt = NsType.fromType(Integer.MIN_VALUE);
assertEquals(nt,NsType.UNKNOWN);
nt = NsType.fromString("Garbage");
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedCertDAOTest.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedCertDAOTest.java
index de004fd5..54da1bf0 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedCertDAOTest.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedCertDAOTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedCredDAOTest.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedCredDAOTest.java
index 7f5ed85c..3d98dcda 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedCredDAOTest.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedCredDAOTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedNSDAOTest.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedNSDAOTest.java
index 064b985c..9298b9fd 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedNSDAOTest.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedNSDAOTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedPermDAOTest.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedPermDAOTest.java
index 46bbc7e6..8a505479 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedPermDAOTest.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedPermDAOTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -47,13 +47,13 @@ public class JU_CachedPermDAOTest {
private CIDAO<AuthzTrans> info;
@Mock
private PermDAO dao;
-
+
@Mock
RoleDAO.Data role;
-
+
@Mock
private PermDAO.Data perm;
-
+
@Mock
private AuthzTrans trans;
@Mock
@@ -65,25 +65,25 @@ public class JU_CachedPermDAOTest {
when(dao.readNS(trans, "ns")).thenReturn(value);
when(trans.debug()).thenReturn(new LogTarget() {
-
+
@Override
public void printf(String fmt, Object... vars) {}
-
+
@Override
public void log(Throwable e, Object... msgs) {
e.getMessage();
e.printStackTrace();
msgs.toString();
-
+
}
-
+
@Override
public void log(Object... msgs) {
}
-
+
@Override
public boolean isLoggable() {
-
+
return true;
}
});
@@ -109,7 +109,7 @@ public class JU_CachedPermDAOTest {
verify(dao).readChildren(trans, "ns", "type");
}
-
+
@Test
public void testReadByTypeSuccess() {
CachedPermDAO roleDaoObj =new CachedPermDAO(dao,info, 10);//Mockito.mock(CachedRoleDAO.class);//
@@ -119,8 +119,8 @@ public class JU_CachedPermDAOTest {
// System.out.println(retVal.status);
//retVal.status = 0;
assertEquals("1", Integer.toString(retVal.status));
- }
-
+ }
+
@Test
public void testReadByTypeFailure() {
CachedPermDAO roleDaoObj =new CachedPermDAO(dao,info, 10);//Mockito.mock(CachedRoleDAO.class);//
@@ -130,7 +130,7 @@ public class JU_CachedPermDAOTest {
//System.out.println(retVal.status);
assertEquals("23", Integer.toString(retVal.status));
}
-
+
@Test
public void testAddRole() {
CachedPermDAO roleDaoObj =new CachedPermDAO(dao,info, 10);
@@ -141,7 +141,7 @@ public class JU_CachedPermDAOTest {
// System.out.println("ret value is::"+retVal);
assertEquals("testAddRole", retVal.toString());
}
-
+
@Test
public void testDelRole() {
CachedPermDAO roleDaoObj =new CachedPermDAO(dao,info, 10);
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedRoleDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedRoleDAO.java
index 4d9527c5..d4062b73 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedRoleDAO.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedRoleDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -42,52 +42,52 @@ import org.onap.aaf.auth.layer.Result;
import org.onap.aaf.misc.env.LogTarget;
-@RunWith(MockitoJUnitRunner.class)
+@RunWith(MockitoJUnitRunner.class)
public class JU_CachedRoleDAO {
@Mock
RoleDAO dao;
-
+
@Mock
CIDAO<AuthzTrans> info;
-
+
@Mock
AuthzTransImpl trans;
-
+
@Mock
RoleDAO.Data data;
-
+
@Mock
PermDAO.Data permData;
-
+
@Before
public void setUp() throws Exception {
initMocks(this);
when(trans.debug()).thenReturn(new LogTarget() {
-
+
@Override
public void printf(String fmt, Object... vars) {}
-
+
@Override
public void log(Throwable e, Object... msgs) {
e.getMessage();
e.printStackTrace();
msgs.toString();
-
+
}
-
+
@Override
public void log(Object... msgs) {
}
-
+
@Override
public boolean isLoggable() {
-
+
return true;
}
});
}
-
+
@Test
public void testReadNameSuccess() {
CachedRoleDAO roleDaoObj =new CachedRoleDAO(dao,info, 10);//Mockito.mock(CachedRoleDAO.class);//
@@ -99,8 +99,8 @@ public class JU_CachedRoleDAO {
// System.out.println(retVal.status);
//retVal.status = 0;
assertEquals("1", Integer.toString(retVal.status));
- }
-
+ }
+
@Test
public void testReadNameFailure() {
CachedRoleDAO roleDaoObj =new CachedRoleDAO(dao,info, 10);//Mockito.mock(CachedRoleDAO.class);//
@@ -120,7 +120,7 @@ public class JU_CachedRoleDAO {
Result<List<Data>> retVal = roleDaoObj.readNS(trans, "");
// System.out.println(retVal.status);
assertEquals("1", Integer.toString(retVal.status));
- }
+ }
@Test
public void testReadNSFailure() {
CachedRoleDAO roleDaoObj =new CachedRoleDAO(dao,info, 10);//Mockito.mock(CachedRoleDAO.class);//
@@ -131,7 +131,7 @@ public class JU_CachedRoleDAO {
// System.out.println(retVal.status);
assertEquals("22", Integer.toString(retVal.status));
}
-
+
@Test
public void testReadChildren() {
CachedRoleDAO roleDaoObj =new CachedRoleDAO(dao,info, 10);//Mockito.mock(CachedRoleDAO.class);//
@@ -141,7 +141,7 @@ public class JU_CachedRoleDAO {
//System.out.println(retVal.status);
assertEquals("0", Integer.toString(retVal.status));
}
-
+
@Test
public void testAddPerm() {
CachedRoleDAO roleDaoObj =new CachedRoleDAO(dao,info, 10);
@@ -151,7 +151,7 @@ public class JU_CachedRoleDAO {
Result<Void> retVal = roleDaoObj.addPerm(trans, data, permData);
assertEquals("testAddPerm", retVal.toString());
}
-
+
@Test
public void testDelPerm() {
CachedRoleDAO roleDaoObj =new CachedRoleDAO(dao,info, 10);
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedUserRoleDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedUserRoleDAO.java
index 053fc889..814a03fe 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedUserRoleDAO.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cached/JU_CachedUserRoleDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -50,47 +50,47 @@ public class JU_CachedUserRoleDAO {
@Mock
UserRoleDAO dao;
-
+
@Mock
CIDAO<AuthzTrans> info;
-
+
@Mock
AuthzTransImpl trans;
-
+
@Mock
RoleDAO.Data data;
-
+
@Mock
PermDAO.Data permData;
-
+
@Before
public void setUp() throws Exception {
initMocks(this);
when(trans.debug()).thenReturn(new LogTarget() {
-
+
@Override
public void printf(String fmt, Object... vars) {}
-
+
@Override
public void log(Throwable e, Object... msgs) {
e.getMessage();
e.printStackTrace();
msgs.toString();
-
+
}
-
+
@Override
public void log(Object... msgs) {
}
-
+
@Override
public boolean isLoggable() {
-
+
return true;
}
});
}
-
+
private class TaggedPrincipalStub extends TaggedPrincipal {
String name="TaggedPrincipalStub";
public TaggedPrincipalStub() { super(); }
@@ -98,7 +98,7 @@ public class JU_CachedUserRoleDAO {
@Override public String getName() { return name; }
@Override public String tag() { return null; }
}
-
+
@Test
public void testReadName() {
CachedUserRoleDAO roleDaoObj =new CachedUserRoleDAO(dao,info, 10L);
@@ -109,8 +109,8 @@ public class JU_CachedUserRoleDAO {
//System.out.println(retVal.status);
//retVal.status = 0;
assertEquals("25", Integer.toString(retVal.status));
- }
-
+ }
+
@Test
public void testReadNameUser() {
CachedUserRoleDAO roleDaoObj =new CachedUserRoleDAO(dao,info, 10L);
@@ -122,7 +122,7 @@ public class JU_CachedUserRoleDAO {
Object o=null;
return (T)o;
}
-
+
};
transTemp.setUser(new TaggedPrincipalStub());
Mockito.doReturn(retVal1).when(info).touch(trans, null,null);
@@ -132,7 +132,7 @@ public class JU_CachedUserRoleDAO {
// System.out.println(retVal.status);
assertEquals("1", Integer.toString(retVal.status));
}
-
+
@Test
public void testReadByRoleSuccess() {
CachedUserRoleDAO roleDaoObj =new CachedUserRoleDAO(dao,info, 0);//Mockito.mock(CachedRoleDAO.class);//
@@ -142,7 +142,7 @@ public class JU_CachedUserRoleDAO {
Result<List<Data>> retVal = roleDaoObj.readByRole(trans, "");
//System.out.println(retVal.status);
assertEquals("1", Integer.toString(retVal.status));
- }
+ }
@Test
public void testReadByRoleFailure() {
CachedUserRoleDAO roleDaoObj =new CachedUserRoleDAO(dao,info, 0);//Mockito.mock(CachedRoleDAO.class);//
@@ -153,7 +153,7 @@ public class JU_CachedUserRoleDAO {
//System.out.println(retVal.status);
assertEquals("25", Integer.toString(retVal.status));
}
-
+
@Test
public void testReadUserInRole() {
CachedUserRoleDAO roleDaoObj =new CachedUserRoleDAO(dao,info, 10);//Mockito.mock(CachedRoleDAO.class);//
@@ -165,7 +165,7 @@ public class JU_CachedUserRoleDAO {
Object o=null;
return (T)o;
}
-
+
};
transTemp.setUser(new TaggedPrincipalStub());
Mockito.doReturn(retVal1).when(info).touch(trans, null,null);
@@ -175,6 +175,6 @@ public class JU_CachedUserRoleDAO {
//System.out.println(retVal.status);
assertEquals("25", Integer.toString(retVal.status));
}
-
+
} \ No newline at end of file
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_ApprovalDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_ApprovalDAO.java
index 2b303673..c990c2fe 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_ApprovalDAO.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_ApprovalDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -60,7 +60,7 @@ public class JU_ApprovalDAO {
AuthzTrans trans;
@Mock
Cluster cluster;
-
+
@Before
public void setUp() throws APIException, IOException {
initMocks(this);
@@ -69,7 +69,7 @@ public class JU_ApprovalDAO {
Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).debug();
Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).info();
}
-
+
@Test
public void testInit() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -82,35 +82,35 @@ public class JU_ApprovalDAO {
PSInfo createPS = Mockito.mock(PSInfo.class);
Result<ResultSet> rs = new Result<ResultSet>(null,0,"test",new String[0]);
Mockito.doReturn(rs).when(createPS).exec(trans, "ApprovalDAOImpl CREATE", data);
-
+
ApprovalDAOImpl daoObj = new ApprovalDAOImpl(trans, cluster, "test",data, createPS);
// data.id
Result<Data> retVal = daoObj.create(trans, data);
assertTrue(retVal.status == 0);
-
+
rs = new Result<ResultSet>(null,1,"test",new String[0]);
Mockito.doReturn(rs).when(createPS).exec(trans, "ApprovalDAOImpl CREATE", data);
retVal = daoObj.create(trans, data);
assertTrue(retVal.status == 1);
-
+
Result<List<ApprovalDAO.Data>> rs1 = new Result<List<ApprovalDAO.Data>>(null,0,"test",new String[0]);
Mockito.doReturn(rs1).when(createPS).read(trans, "ApprovalDAOImpl CREATE", new Object[]{"testUser"});
Result<List<ApprovalDAO.Data>> retVal1 = daoObj.readByUser(trans, "testUser");
assertNull(retVal1);
-
+
Mockito.doReturn(rs1).when(createPS).read(trans, "ApprovalDAOImpl CREATE", new Object[]{"testApprover"});
retVal1 = daoObj.readByApprover(trans, "testApprover");
assertNull(retVal1);
-
+
Mockito.doReturn(rs1).when(createPS).read(trans, "ApprovalDAOImpl CREATE", new Object[]{new UUID(0, 0)});
retVal1 = daoObj.readByTicket(trans, new UUID(0, 0));
assertNull(retVal1);
-
+
Mockito.doReturn(rs1).when(createPS).read(trans, "ApprovalDAOImpl CREATE", new Object[]{"testStatus"});
retVal1 = daoObj.readByStatus(trans, "testStatus");
assertNull(retVal1);
}
-
+
@Test
public void testDelete() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -125,28 +125,28 @@ public class JU_ApprovalDAO {
HistoryDAO historyDAO = Mockito.mock(HistoryDAO.class);
Result<ResultSet> rs1 = new Result<ResultSet>(null,0,"test",new String[0]);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
-
+
PSInfo createPS = Mockito.mock(PSInfo.class);
ResultSet rsObj = new ResultSetImpl();
Result<ResultSet> rs = new Result<ResultSet>(rsObj,0,"test",new String[0]);
Mockito.doReturn(rs).when(createPS).exec(trans, "ApprovalDAOImpl READ", data);
Mockito.doReturn(rs).when(createPS).exec(trans, "ApprovalDAOImpl DELETE", data);
-
+
ApprovalDAOImpl daoObj = new ApprovalDAOImpl(trans, cluster, "test", createPS, historyDAO);
// data.id
Result<Void> retVal = daoObj.delete(trans, data, true);
assertTrue(retVal.status == 0);
-
+
rs = new Result<ResultSet>(rsObj,1,"test",new String[0]);
Mockito.doReturn(rs).when(createPS).exec(trans, "ApprovalDAOImpl READ", data);
retVal = daoObj.delete(trans, data, true);
assertTrue(retVal.status == 1);
-
+
data.status="approved";
data.memo="test";
retVal = daoObj.delete(trans, data, false);
assertTrue(retVal.status == 0);
-
+
daoObj.async(true);
data.status="denied";
retVal = daoObj.delete(trans, data, false);
@@ -155,7 +155,7 @@ public class JU_ApprovalDAO {
data.status=null;
retVal = daoObj.delete(trans, data, false);
}
-
+
@Test
public void testWasMOdified() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -167,24 +167,24 @@ public class JU_ApprovalDAO {
Mockito.doNothing().when(tt).done();
ApprovalDAO.Data data = new ApprovalDAO.Data();
PSInfo createPS = Mockito.mock(PSInfo.class);
-
+
HistoryDAO historyDAO = Mockito.mock(HistoryDAO.class);
Result<ResultSet> rs1 = new Result<ResultSet>(null,0,"test",new String[0]);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
-
+
ApprovalDAOImpl daoObj = new ApprovalDAOImpl(trans, cluster, "test", createPS, historyDAO);
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test"});
-
+
daoObj.wasModified(trans, CRUD.create, data, new String[] {});
daoObj.wasModified(trans, CRUD.create, data, new String[] {null});
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test",null});
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test","test"});
-
+
rs1 = new Result<ResultSet>(null,1,"test",new String[0]);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test","test"});
}
-
+
@Test
public void testSecondConstructor() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -196,7 +196,7 @@ public class JU_ApprovalDAO {
Mockito.doNothing().when(tt).done();
ApprovalDAO.Data data = new ApprovalDAO.Data();
HistoryDAO historyDAO = Mockito.mock(HistoryDAO.class);
-
+
ApprovalDAO daoObj = new ApprovalDAO(trans, historyDAO);
}
}
@@ -270,7 +270,7 @@ class ResultSetImpl implements ResultSet{
// TODO Auto-generated method stub
return false;
}
-
+
}
class ApprovalDAOImpl extends ApprovalDAO{
@@ -283,12 +283,12 @@ class ApprovalDAOImpl extends ApprovalDAO{
setPs(this, createPS, "psByTicket");
setPs(this, createPS, "psByStatus");
}
-
+
public ApprovalDAOImpl(AuthzTrans trans, Cluster cluster, String keyspace,PSInfo readPS ) {
super(trans, cluster, keyspace);
this.readPS = readPS;
}
-
+
public ApprovalDAOImpl(AuthzTrans trans, Cluster cluster, String keyspace,PSInfo readPS, HistoryDAO historyDAO ) {
super(trans, cluster, keyspace);
this.deletePS = readPS;
@@ -296,18 +296,18 @@ class ApprovalDAOImpl extends ApprovalDAO{
setHistoryDao(this, historyDAO);
setSession(this, Mockito.mock(Session.class));
}
-
+
public void setPs(ApprovalDAOImpl approvalDaoObj, PSInfo psInfoObj, String methodName) {
Field nsDaoField;
try {
nsDaoField = ApprovalDAO.class.getDeclaredField(methodName);
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
nsDaoField.set(approvalDaoObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -325,13 +325,13 @@ class ApprovalDAOImpl extends ApprovalDAO{
Field nsDaoField;
try {
nsDaoField = ApprovalDAO.class.getDeclaredField("historyDAO");
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
nsDaoField.set(approvalDaoObj, historyDAO);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -348,13 +348,13 @@ class ApprovalDAOImpl extends ApprovalDAO{
Field nsDaoField;
try {
nsDaoField = AbsCassDAO.class.getDeclaredField("session");
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
nsDaoField.set(approvalDaoObj, session);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_ArtiDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_ArtiDAO.java
index d6e1fb55..c71da3bc 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_ArtiDAO.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_ArtiDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -59,7 +59,7 @@ public class JU_ArtiDAO {
AuthzTrans trans;
@Mock
Cluster cluster;
-
+
@Before
public void setUp() throws APIException, IOException {
initMocks(this);
@@ -68,7 +68,7 @@ public class JU_ArtiDAO {
Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).debug();
Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).info();
}
-
+
@Test
public void testReadByMechID() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -77,17 +77,17 @@ public class JU_ArtiDAO {
Mockito.doReturn(tt).when(trans).start("New Cassandra Session", Env.SUB);
Mockito.doReturn(tt).when(trans).start("Preparing PSInfo CREATE on ArtiDAO", Env.SUB);
Mockito.doNothing().when(tt).done();
-
+
PSInfo psByMechIdObj = Mockito.mock(PSInfo.class);
Result<ResultSet> rs = new Result<ResultSet>(null,0,"test",new String[0]);
// Mockito.doReturn(rs).when(createPS).exec(trans, "ArtiDAOImpl CREATE", data);
-
+
ArtiDAOImpl daoObj = new ArtiDAOImpl(trans, cluster, "test", psByMechIdObj);
-
+
Result<List<ArtiDAO.Data>> rs1 = new Result<List<ArtiDAO.Data>>(null,0,"test",new String[0]);
Mockito.doReturn(rs1).when(psByMechIdObj).read(trans, "ArtiDAOImpl READ", new Object[]{"testMechId"});
daoObj.readByMechID(trans, "testMechId");
-
+
rs1 = new Result<List<ArtiDAO.Data>>(null,0,"test",new String[0]);
Mockito.doReturn(rs1).when(psByMechIdObj).read(trans, "ArtiDAOImpl READ", new Object[]{"testMachine"});
daoObj.readByMachine(trans, "testMachine");
@@ -96,7 +96,7 @@ public class JU_ArtiDAO {
Mockito.doReturn(rs1).when(psByMechIdObj).read(trans, "ArtiDAOImpl READ", new Object[]{"testNs"});
daoObj.readByNs(trans, "testNs");
}
-
+
@Test
public void testWasMOdified() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -108,43 +108,43 @@ public class JU_ArtiDAO {
Mockito.doNothing().when(tt).done();
ArtiDAO.Data data = new ArtiDAO.Data();
PSInfo createPS = Mockito.mock(PSInfo.class);
-
+
HistoryDAO historyDAO = Mockito.mock(HistoryDAO.class);
Result<ResultSet> rs1 = new Result<ResultSet>(null,0,"test",new String[0]);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
-
+
ArtiDAOImpl daoObj = new ArtiDAOImpl(trans, cluster, "test", createPS, historyDAO);
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test"});
-
+
daoObj.wasModified(trans, CRUD.create, data, new String[] {});
daoObj.wasModified(trans, CRUD.create, data, new String[] {null});
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test",null});
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test","test"});
-
+
rs1 = new Result<ResultSet>(null,1,"test",new String[0]);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test","test"});
-
+
data.type(true);
daoObj.wasModified(trans, CRUD.delete, data, new String[] {"test","test"});
-
+
}
@Test
public void testData(){
ArtiDAO.Data data = new ArtiDAO.Data();
data.type(true);
data.type(false);
-
+
data.sans(true);
data.sans(false);
data.sans = new TreeSet();
data.sans(false);
data.sans(true);
-
+
data.expires = new Date();
data.toString();
}
-
+
@Test
public void testArtifactLoader(){
ArtiDAO daoObj = new ArtiDAO(trans, cluster, "test");
@@ -154,18 +154,18 @@ public class JU_ArtiDAO {
try {
Object obj = constructor.newInstance(10);
Method innnerClassMtd;
-
+
ArtiDAO.Data data = new ArtiDAO.Data();
Row row = Mockito.mock(Row.class);
innnerClassMtd = innerClass.getMethod("load", new Class[] {ArtiDAO.Data.class, Row.class});
innnerClassMtd.invoke(obj, new Object[] {data, row});
-
+
innnerClassMtd = innerClass.getDeclaredMethod("key", new Class[] {ArtiDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test"} });
-
+
innnerClassMtd = innerClass.getDeclaredMethod("body", new Class[] {ArtiDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test","test","test","test","test","test","test","test","test"} });
-
+
// DataInputStream in = Mockito.mock(DataInputStream.class);
//// Mockito.doReturn(100).when(in).read();
//// Mockito.doReturn(100).when(in).readInt();
@@ -189,9 +189,9 @@ public class JU_ArtiDAO {
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- }
+ }
}
-
+
@Test
public void testSecondConstructor() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -203,10 +203,10 @@ public class JU_ArtiDAO {
Mockito.doNothing().when(tt).done();
ArtiDAO.Data data = new ArtiDAO.Data();
HistoryDAO historyDAO = Mockito.mock(HistoryDAO.class);
-
+
ArtiDAO daoObj = new ArtiDAO(trans, historyDAO, Mockito.mock(CacheInfoDAO.class));
}
-
+
}
@@ -219,7 +219,7 @@ class ArtiDAOImpl extends ArtiDAO{
setPs(this, createPS, "psByMachine");
setPs(this, createPS, "psByNs");
}
-
+
public ArtiDAOImpl(AuthzTrans trans, Cluster cluster, String keyspace,PSInfo readPS, HistoryDAO historyDAO ) {
super(trans, cluster, keyspace);
this.deletePS = readPS;
@@ -227,18 +227,18 @@ class ArtiDAOImpl extends ArtiDAO{
setHistoryDao(this, historyDAO);
setSession(this, Mockito.mock(Session.class));
}
-
+
public void setPs(ArtiDAOImpl ArtiDAOObj, PSInfo psInfoObj, String methodName) {
Field nsDaoField;
try {
nsDaoField = ArtiDAO.class.getDeclaredField(methodName);
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
nsDaoField.set(ArtiDAOObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -256,13 +256,13 @@ class ArtiDAOImpl extends ArtiDAO{
Field nsDaoField;
try {
nsDaoField = ArtiDAO.class.getDeclaredField("historyDAO");
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
nsDaoField.set(ArtiDAOObj, historyDAO);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -279,13 +279,13 @@ class ArtiDAOImpl extends ArtiDAO{
Field nsDaoField;
try {
nsDaoField = AbsCassDAO.class.getDeclaredField("session");
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
nsDaoField.set(ArtiDAOObj, session);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_CacheInfoDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_CacheInfoDAO.java
index c23a3729..695de1f0 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_CacheInfoDAO.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_CacheInfoDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -77,7 +77,7 @@ public class JU_CacheInfoDAO {
AuthzEnv env;
@Mock
LogTarget logTarget;
-
+
@Before
public void setUp() throws APIException, IOException {
initMocks(this);
@@ -90,7 +90,7 @@ public class JU_CacheInfoDAO {
Mockito.doReturn("100").when(trans).getProperty(Config.CADI_LONGITUDE);
Mockito.doReturn(session).when(cluster).connect("test");
}
-
+
@Test
public void testInit() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -103,7 +103,7 @@ public class JU_CacheInfoDAO {
PSInfo createPS = Mockito.mock(PSInfo.class);
Result<ResultSet> rs = new Result<ResultSet>(null,0,"test",new String[0]);
Mockito.doReturn(rs).when(createPS).exec(trans, "CacheInfoDAOImpl CREATE", data);
-
+
CacheInfoDAOImpl daoObj=null;
try {
daoObj = new CacheInfoDAOImpl(trans, cluster, "test",data, createPS);
@@ -115,7 +115,7 @@ public class JU_CacheInfoDAO {
Result<Data> retVal = daoObj.create(trans, data);
assertTrue(retVal.status == 0);
}
-
+
@Test
public void testTouch() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -128,12 +128,12 @@ public class JU_CacheInfoDAO {
Mockito.doNothing().when(tt).done();
Mockito.doReturn(logTarget).when(env).debug();
-
+
CacheInfoDAO.Data data = new CacheInfoDAO.Data();
PSInfo createPS = Mockito.mock(PSInfo.class);
Result<ResultSet> rs = new Result<ResultSet>(null,0,"test",new String[0]);
Mockito.doReturn(rs).when(createPS).exec(trans, "CacheInfoDAOImpl CREATE", data);
-
+
CacheInfoDAOImpl daoObj=null;
try {
daoObj = new CacheInfoDAOImpl(trans, cluster, "test",data, createPS);
@@ -147,8 +147,8 @@ public class JU_CacheInfoDAO {
Mockito.doThrow(DriverException.class).when(session).executeAsync(Mockito.anyString());
daoObj.startUpdate(env, Mockito.mock(HMangr.class), Mockito.mock(SecuritySetter.class), "12.0.0.1", 8080);
retVal = daoObj.touch(trans, "test", 1, 2);
-
-
+
+
try {
daoObj = new CacheInfoDAOImpl(trans, cluster, "test",data, createPS);
} catch (APIException | IOException e) {
@@ -175,7 +175,7 @@ public class JU_CacheInfoDAO {
retVal = daoObj.touch(trans, "test", 1, 2);
assertTrue(retVal.status == Result.ERR_Backend);
}
-
+
@Test
public void testCheck() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -189,7 +189,7 @@ public class JU_CacheInfoDAO {
PSInfo createPS = Mockito.mock(PSInfo.class);
Result<ResultSet> rs = new Result<ResultSet>(null,0,"test",new String[0]);
Mockito.doReturn(rs).when(createPS).exec(trans, "CacheInfoDAOImpl CREATE", data);
-
+
CacheInfoDAOImpl daoObj=null;
PreparedStatement ps = Mockito.mock(PreparedStatement.class);
Mockito.doReturn(ps).when(session).prepare(Mockito.anyString());
@@ -208,7 +208,7 @@ public class JU_CacheInfoDAO {
Mockito.doReturn(resultSet).when(session).execute(Mockito.any(Statement.class));
Result<Void> retVal = daoObj.check(trans);
assertTrue(retVal.status == 0);
-
+
Row row = Mockito.mock(Row.class);
Mockito.doReturn("test").when(row).getString(Mockito.anyInt());
rowList.add(row);
@@ -243,9 +243,9 @@ public class JU_CacheInfoDAO {
}
@Test
public void testStopUpdate() {
-
+
CacheInfoDAO.stopUpdate();
-
+
}
@@ -264,7 +264,7 @@ public class JU_CacheInfoDAO {
PSInfo createPS = Mockito.mock(PSInfo.class);
Result<ResultSet> rs = new Result<ResultSet>(null,0,"test",new String[0]);
Mockito.doReturn(rs).when(createPS).exec(trans, "CacheInfoDAOImpl CREATE", data);
-
+
CacheInfoDAOImpl daoObj=null;
try {
daoObj = new CacheInfoDAOImpl(trans, cluster, "test",data, createPS);
@@ -276,7 +276,7 @@ public class JU_CacheInfoDAO {
}
}
*/
-
+
@Test
public void testWasMOdified() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -288,11 +288,11 @@ public class JU_CacheInfoDAO {
Mockito.doNothing().when(tt).done();
CacheInfoDAO.Data data = new CacheInfoDAO.Data("test",1);
PSInfo createPS = Mockito.mock(PSInfo.class);
-
+
HistoryDAO historyDAO = Mockito.mock(HistoryDAO.class);
Result<ResultSet> rs1 = new Result<ResultSet>(null,0,"test",new String[0]);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
-
+
CacheInfoDAOImpl daoObj=null;
try {
daoObj = new CacheInfoDAOImpl(trans, cluster, "test", createPS);
@@ -301,10 +301,10 @@ public class JU_CacheInfoDAO {
e.printStackTrace();
}
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test"});
-
-
+
+
}
-
+
@Test
public void testInfoLoader(){
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -338,12 +338,12 @@ public class JU_CacheInfoDAO {
try {
Object obj = constructor.newInstance(1);
Method innnerClassMtd;
-
+
CacheInfoDAO.Data data = new CacheInfoDAO.Data();
Row row = Mockito.mock(Row.class);
innnerClassMtd = innerClass.getMethod("load", new Class[] {CacheInfoDAO.Data.class, Row.class});
innnerClassMtd.invoke(obj, new Object[] {data, row});
-
+
innnerClassMtd = innerClass.getDeclaredMethod("key", new Class[] {CacheInfoDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test"}});
@@ -367,9 +367,9 @@ public class JU_CacheInfoDAO {
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- }
+ }
}
-
+
@Test
public void testCacheUpdate(){
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -407,24 +407,24 @@ public class JU_CacheInfoDAO {
Constructor<?> innerConstructor = innerInnerClass.getDeclaredConstructors()[0];
innerConstructor.setAccessible(true);
Object innerClassObj = innerConstructor.newInstance(obj, trans);
-
+
Method innnerClassMtd;
-
+
CacheInfoDAO.Data data = new CacheInfoDAO.Data();
Row row = Mockito.mock(Row.class);
Rcli rcli = Mockito.mock(Rcli.class);
URI uri = new URI("ftp","admin:admin@geeksforgeeks.org:1234","/path/data","tt","ttd");
Mockito.doReturn(uri).when(rcli).getURI();
Mockito.doReturn(Mockito.mock(org.onap.aaf.cadi.client.Future.class)).when(rcli).delete("/mgmt/cache/null/null", "application/Void+json;q=1.0;charset=utf-8;version=2.0,application/json;q=1.0;version=2.0,*/*;q=1.0");
-
+
innnerClassMtd = innerInnerClass.getMethod("code", new Class[] {Rcli.class});
innnerClassMtd.invoke(innerClassObj, new Object[] {rcli});
-
+
org.onap.aaf.cadi.client.Future futureObj = Mockito.mock(org.onap.aaf.cadi.client.Future.class);
Mockito.doReturn(futureObj).when(rcli).delete("/mgmt/cache/null/null", "application/Void+json;q=1.0;charset=utf-8;version=2.0,application/json;q=1.0;version=2.0,*/*;q=1.0");
Mockito.doReturn(true).when(futureObj).get(0);
innnerClassMtd.invoke(innerClassObj, new Object[] {rcli});
-
+
uri = new URI("ftp","12.0.0.1:8080","/path/data","tt","ttd");
Mockito.doReturn(uri).when(rcli).getURI();
innnerClassMtd.invoke(innerClassObj, new Object[] {rcli});
@@ -458,9 +458,9 @@ public class JU_CacheInfoDAO {
} catch (CadiException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- }
+ }
}
-
+
@Test
public void testIntHolder(){
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -499,16 +499,16 @@ public class JU_CacheInfoDAO {
innerConstructor.setAccessible(true);
int[] a = new int[10];
Object innerClassObj = innerConstructor.newInstance(obj, a);
-
+
Method innnerClassMtd=null;
-
+
CacheInfoDAO.Data data = new CacheInfoDAO.Data();
Row row = Mockito.mock(Row.class);
Rcli rcli = Mockito.mock(Rcli.class);
URI uri = new URI("ftp","admin:admin@geeksforgeeks.org:1234","/path/data","tt","ttd");
Mockito.doReturn(uri).when(rcli).getURI();
Mockito.doReturn(Mockito.mock(org.onap.aaf.cadi.client.Future.class)).when(rcli).delete("/mgmt/cache/null/null", "application/Void+json;q=1.0;charset=utf-8;version=2.0,application/json;q=1.0;version=2.0,*/*;q=1.0");
-
+
Method[] allMtds = innerInnerClass.getDeclaredMethods();
for(Method indMtd:allMtds) {
if(indMtd.getName().contains("add")) {
@@ -516,8 +516,8 @@ public class JU_CacheInfoDAO {
}
}
innnerClassMtd.invoke(innerClassObj, new Object[] {a});
-
-
+
+
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -545,9 +545,9 @@ public class JU_CacheInfoDAO {
} catch (CadiException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- }
+ }
}
-
+
//@Test
public void testSecondConstructor() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -580,24 +580,24 @@ class CacheInfoDAOImpl extends CacheInfoDAO{
// setPs(this, createPS, "psByStatus");
// setSession(this, Mockito.mock(Session.class));
}
-
+
public CacheInfoDAOImpl(AuthzTrans trans, Cluster cluster, String keyspace,PSInfo readPS ) throws APIException, IOException {
super(trans, cluster, keyspace);
this.readPS = readPS;
}
-
+
public void setPs(CacheInfoDAOImpl CacheInfoDAOObj, PSInfo psInfoObj, String methodName) {
Field nsDaoField;
try {
nsDaoField = CacheInfoDAO.class.getDeclaredField(methodName);
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
nsDaoField.set(CacheInfoDAOObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -611,12 +611,12 @@ class CacheInfoDAOImpl extends CacheInfoDAO{
}
}
-
+
public void setSession(CacheInfoDAOImpl CacheInfoDAOObj, Session session) {
Field nsDaoField;
try {
nsDaoField = AbsCassDAO.class.getDeclaredField("session");
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
@@ -634,5 +634,5 @@ class CacheInfoDAOImpl extends CacheInfoDAO{
e.printStackTrace();
}
}
-
+
}
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_CertDAOTest.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_CertDAOTest.java
index 782bd985..718d9dec 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_CertDAOTest.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_CertDAOTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -66,7 +66,7 @@ public class JU_CertDAOTest {
AuthzEnv env;
@Mock
LogTarget logTarget;
-
+
@Before
public void setUp() throws APIException, IOException {
initMocks(this);
@@ -79,7 +79,7 @@ public class JU_CertDAOTest {
Mockito.doReturn("100").when(trans).getProperty(Config.CADI_LONGITUDE);
Mockito.doReturn(session).when(cluster).connect("test");
}
-
+
@Test
public void testInit() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -92,7 +92,7 @@ public class JU_CertDAOTest {
PSInfo createPS = Mockito.mock(PSInfo.class);
Result<ResultSet> rs = new Result<ResultSet>(null,0,"test",new String[0]);
Mockito.doReturn(rs).when(createPS).exec(trans, "CertDAOImpl CREATE", data);
-
+
CertDAOImpl daoObj=null;
try {
daoObj = new CertDAOImpl(trans, cluster, "test",data, createPS);
@@ -102,17 +102,17 @@ public class JU_CertDAOTest {
}
}
-
+
@Test
public void testCertLoader(){
-
+
Class<?> innerClass = CertDAO.class.getDeclaredClasses()[0];
Constructor<?> constructor = innerClass.getDeclaredConstructors()[0];
constructor.setAccessible(true);
try {
Object obj = constructor.newInstance(1);
Method innnerClassMtd;
-
+
CertDAO.Data data = new CertDAO.Data();
Row row = Mockito.mock(Row.class);
ByteBuffer bbObj = ByteBuffer.allocateDirect(10);
@@ -121,16 +121,16 @@ public class JU_CertDAOTest {
bbObj.put(1, new Byte("1"));
bbObj.put(2, new Byte("2"));
Mockito.doReturn(bbObj).when(row).getBytesUnsafe(1);
-
+
innnerClassMtd = innerClass.getMethod("load", new Class[] {CertDAO.Data.class, Row.class});
innnerClassMtd.invoke(obj, new Object[] {data, row});
-
+
innnerClassMtd = innerClass.getDeclaredMethod("key", new Class[] {CertDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test"} });
-//
+//
innnerClassMtd = innerClass.getDeclaredMethod("body", new Class[] {CertDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test","test","test","test","test","test","test","test","test"} });
-
+
// DataInputStream in = Mockito.mock(DataInputStream.class);
//// Mockito.doReturn(100).when(in).read();
//// Mockito.doReturn(100).when(in).readInt();
@@ -154,9 +154,9 @@ public class JU_CertDAOTest {
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- }
+ }
}
-
+
@Test
public void testWasMOdified() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -168,14 +168,14 @@ public class JU_CertDAOTest {
Mockito.doNothing().when(tt).done();
CertDAO.Data data = new CertDAO.Data();
PSInfo createPS = Mockito.mock(PSInfo.class);
-
+
HistoryDAO historyDAO = Mockito.mock(HistoryDAO.class);
Result<ResultSet> rs1 = new Result<ResultSet>(null,0,"test",new String[0]);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
-
+
CacheInfoDAO cacheInfoDAO = Mockito.mock(CacheInfoDAO.class);
Mockito.doReturn(rs1).when(cacheInfoDAO).touch(trans, CertDAO.TABLE, new int[1]);
-
+
CertDAO daoObj = null;
try {
daoObj = new CertDAO(trans, historyDAO, cacheInfoDAO);
@@ -183,21 +183,21 @@ public class JU_CertDAOTest {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test"});
-
+
rs1 = new Result<ResultSet>(null,1,"test",new String[0]);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
-
+
Mockito.doReturn(rs1).when(cacheInfoDAO).touch(trans, CertDAO.TABLE, new int[1]);
-
+
try {
daoObj = new CertDAO(trans, historyDAO, cacheInfoDAO);
} catch (APIException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test"});
daoObj.wasModified(trans, CRUD.delete, data, new String[] {"test"});
@@ -205,7 +205,7 @@ public class JU_CertDAOTest {
daoObj.wasModified(trans, CRUD.delete, data, new String[] {"test", "test"});
daoObj.wasModified(trans, CRUD.delete, data, new String[] {null});
daoObj.wasModified(trans, CRUD.delete, data, new String[] {});
-
+
try {
CertDAO.Data data1 = Mockito.mock(CertDAO.Data.class);
Mockito.doThrow(new IOException()).when(data1).bytify();
@@ -216,7 +216,7 @@ public class JU_CertDAOTest {
e.printStackTrace();
}
}
-
+
@Test
public void testRead() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -235,14 +235,14 @@ public class JU_CertDAOTest {
Mockito.doNothing().when(tt).done();
CertDAO.Data data = new CertDAO.Data();
PSInfo createPS = Mockito.mock(PSInfo.class);
-
+
HistoryDAO historyDAO = Mockito.mock(HistoryDAO.class);
Result<ResultSet> rs1 = new Result<ResultSet>(null,0,"test",new String[0]);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
-
+
CacheInfoDAO cacheInfoDAO = Mockito.mock(CacheInfoDAO.class);
Mockito.doReturn(rs1).when(cacheInfoDAO).touch(trans, CertDAO.TABLE, new int[1]);
-
+
CertDAOImpl daoObj = null;
try {
daoObj = new CertDAOImpl(trans, historyDAO, cacheInfoDAO, createPS);
@@ -250,15 +250,15 @@ public class JU_CertDAOTest {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
daoObj.read(trans, new Object[] {"test", BigInteger.ONE});
Field cbField;
try {
cbField = CassAccess.class.getDeclaredField("cb");
-
+
cbField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
cbField.set(null, null);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -270,15 +270,15 @@ public class JU_CertDAOTest {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
daoObj.readX500(trans, "test");
-
+
try {
cbField = CassAccess.class.getDeclaredField("cb");
-
+
cbField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
cbField.set(null, null);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -290,11 +290,11 @@ public class JU_CertDAOTest {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
- daoObj.readID(trans, "test");
+
+ daoObj.readID(trans, "test");
}
-
+
@Test
public void testSecondConstructor() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -328,24 +328,24 @@ class CertDAOImpl extends CertDAO{
// setPs(this, createPS, "psByStatus");
// setSession(this, Mockito.mock(Session.class));
}
-
+
public CertDAOImpl(AuthzTrans trans, HistoryDAO historyDAO, CacheInfoDAO cacheInfoDAO,PSInfo readPS ) throws APIException, IOException {
super(trans, historyDAO, cacheInfoDAO);
this.readPS = readPS;
}
-
+
public void setPs(CertDAOImpl CertDAOObj, PSInfo psInfoObj, String methodName) {
Field nsDaoField;
try {
nsDaoField = CertDAO.class.getDeclaredField(methodName);
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
nsDaoField.set(CertDAOObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -359,12 +359,12 @@ class CertDAOImpl extends CertDAO{
}
}
-
+
public void setSession(CertDAOImpl CertDAOObj, Session session) {
Field nsDaoField;
try {
nsDaoField = AbsCassDAO.class.getDeclaredField("session");
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
@@ -382,5 +382,5 @@ class CertDAOImpl extends CertDAO{
e.printStackTrace();
}
}
-
+
}
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_ConfigDAOTest.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_ConfigDAOTest.java
index 91d16970..30004e91 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_ConfigDAOTest.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_ConfigDAOTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -73,7 +73,7 @@ public class JU_ConfigDAOTest {
AuthzEnv env;
@Mock
LogTarget logTarget;
-
+
@Before
public void setUp() throws APIException, IOException {
initMocks(this);
@@ -86,7 +86,7 @@ public class JU_ConfigDAOTest {
Mockito.doReturn("100").when(trans).getProperty(Config.CADI_LONGITUDE);
Mockito.doReturn(session).when(cluster).connect("test");
}
-
+
@Test
public void testInit() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -99,7 +99,7 @@ public class JU_ConfigDAOTest {
PSInfo createPS = Mockito.mock(PSInfo.class);
Result<ResultSet> rs = new Result<ResultSet>(null,0,"test",new String[0]);
Mockito.doReturn(rs).when(createPS).exec(trans, "ConfigDAOImpl CREATE", data);
-
+
ConfigDAO daoObj=null;
try {
daoObj = new ConfigDAO(trans, cluster, "test");
@@ -109,17 +109,17 @@ public class JU_ConfigDAOTest {
}
}
-
+
@Test
public void testConfigLoader(){
-
+
Class<?> innerClass = ConfigDAO.class.getDeclaredClasses()[0];
Constructor<?> constructor = innerClass.getDeclaredConstructors()[0];
constructor.setAccessible(true);
try {
Object obj = constructor.newInstance(1);
Method innnerClassMtd;
-
+
ConfigDAO.Data data = new ConfigDAO.Data();
Row row = Mockito.mock(Row.class);
ByteBuffer bbObj = ByteBuffer.allocateDirect(10);
@@ -128,16 +128,16 @@ public class JU_ConfigDAOTest {
bbObj.put(1, new Byte("1"));
bbObj.put(2, new Byte("2"));
Mockito.doReturn(bbObj).when(row).getBytesUnsafe(1);
-
+
innnerClassMtd = innerClass.getMethod("load", new Class[] {ConfigDAO.Data.class, Row.class});
innnerClassMtd.invoke(obj, new Object[] {data, row});
-
+
innnerClassMtd = innerClass.getDeclaredMethod("key", new Class[] {ConfigDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test"} });
-//
+//
innnerClassMtd = innerClass.getDeclaredMethod("body", new Class[] {ConfigDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test","test","test","test","test","test","test","test","test"} });
-
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
innnerClassMtd = innerClass.getDeclaredMethod("marshal", new Class[] {ConfigDAO.Data.class, DataOutputStream.class });
@@ -147,7 +147,7 @@ public class JU_ConfigDAOTest {
DataInputStream dis = new DataInputStream(bais);
innnerClassMtd = innerClass.getDeclaredMethod("unmarshal", new Class[] {ConfigDAO.Data.class, DataInputStream.class });
innnerClassMtd.invoke(obj, new Object[] {data, dis });
-
+
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -166,9 +166,9 @@ public class JU_ConfigDAOTest {
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- }
+ }
}
-
+
@Test
public void testWasMOdified() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -180,7 +180,7 @@ public class JU_ConfigDAOTest {
Mockito.doNothing().when(tt).done();
ConfigDAO.Data data = new ConfigDAO.Data();
PSInfo createPS = Mockito.mock(PSInfo.class);
-
+
ConfigDAO daoObj = null;
try {
daoObj = new ConfigDAO(trans, cluster, "test");
@@ -188,13 +188,13 @@ public class JU_ConfigDAOTest {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test"});
-
-
-
+
+
+
}
-
+
@Test
public void testRead() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -210,9 +210,9 @@ public class JU_ConfigDAOTest {
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_USER_NAME,null);
Mockito.doReturn(Mockito.mock(Decryptor.class)).when(trans).decryptor();
Mockito.doNothing().when(tt).done();
-
+
Result<List<Data>> rs1 = new Result<List<Data>>(null,0,"test",new String[0]);
-
+
PSInfo psObj = Mockito.mock(PSInfo.class);
ConfigDAOImpl daoObj = null;
@@ -224,12 +224,12 @@ public class JU_ConfigDAOTest {
}
Mockito.doReturn(rs1).when(psObj).read(trans, "ConfigDAO READ", new Object[]{"test"});
daoObj.readName(trans, "test");
-
-
+
+
}
-
-
+
+
@Test
public void testSecondConstructor() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -252,24 +252,24 @@ public class JU_ConfigDAOTest {
class ConfigDAOImpl extends ConfigDAO{
-
+
public ConfigDAOImpl(AuthzTrans trans, Cluster cluster, String keyspace,PSInfo readPS ) throws APIException, IOException {
super(trans, cluster, keyspace);
setPs(this, readPS, "psName");
}
-
+
public void setPs(ConfigDAOImpl ConfigDAOObj, PSInfo psInfoObj, String methodName) {
Field nsDaoField;
try {
nsDaoField = ConfigDAO.class.getDeclaredField(methodName);
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
nsDaoField.set(ConfigDAOObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -283,12 +283,12 @@ class ConfigDAOImpl extends ConfigDAO{
}
}
-
+
public void setSession(ConfigDAOImpl ConfigDAOObj, Session session) {
Field nsDaoField;
try {
nsDaoField = AbsCassDAO.class.getDeclaredField("session");
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
@@ -306,5 +306,5 @@ class ConfigDAOImpl extends ConfigDAO{
e.printStackTrace();
}
}
-
+
}
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_DelegateDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_DelegateDAO.java
index 39d7492a..3826fcbe 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_DelegateDAO.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_DelegateDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -51,7 +51,7 @@ public class JU_DelegateDAO {
AuthzTrans trans;
@Mock
Cluster cluster;
-
+
@Before
public void setUp() throws APIException, IOException {
initMocks(this);
@@ -65,27 +65,27 @@ public class JU_DelegateDAO {
@Test
public void testReadByDelegate() {
DelegateDAO daoObj = new DelegateDAO(trans, cluster, "test");
-
+
PSInfo psObj = Mockito.mock(PSInfo.class);
setPsDelegate(daoObj, psObj, "psByDelegate");
-
+
Result<List<DelegateDAO.Data>> rs1 = new Result<List<DelegateDAO.Data>>(null,0,"test",new String[0]);
Mockito.doReturn(rs1).when(psObj).read(trans, "DelegateDAO READ", new Object[]{"test"});
-
+
daoObj.readByDelegate(trans, "test");
}
-
+
public void setPsDelegate(DelegateDAO delegateDAOObj, PSInfo psInfoObj, String fieldName) {
Field nsDaoField;
try {
nsDaoField = DelegateDAO.class.getDeclaredField(fieldName);
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
nsDaoField.set(delegateDAOObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -98,13 +98,13 @@ public class JU_DelegateDAO {
e.printStackTrace();
}
}
-
+
@Test
public void testSecondConstructor() {
AbsCassDAO absDAO = Mockito.mock(AbsCassDAO.class);
DelegateDAO daoObj = new DelegateDAO(trans, absDAO);
-
+
}
@Test
@@ -117,13 +117,13 @@ public class JU_DelegateDAO {
break;
}
}
-
+
Constructor<?> constructor = innerClass.getDeclaredConstructors()[0];
constructor.setAccessible(true);
try {
Object obj = constructor.newInstance(1);
Method innnerClassMtd;
-
+
DelegateDAO.Data data = new DelegateDAO.Data();
Row row = Mockito.mock(Row.class);
ByteBuffer bbObj = ByteBuffer.allocateDirect(10);
@@ -132,16 +132,16 @@ public class JU_DelegateDAO {
bbObj.put(1, new Byte("1"));
bbObj.put(2, new Byte("2"));
Mockito.doReturn(bbObj).when(row).getBytesUnsafe(1);
-
+
innnerClassMtd = innerClass.getMethod("load", new Class[] {DelegateDAO.Data.class, Row.class});
innnerClassMtd.invoke(obj, new Object[] {data, row});
-
+
innnerClassMtd = innerClass.getDeclaredMethod("key", new Class[] {DelegateDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test"} });
-//
+//
innnerClassMtd = innerClass.getDeclaredMethod("body", new Class[] {DelegateDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test","test","test","test","test","test","test","test","test"} });
-
+
// DataOutputStream dos = new DataOutputStream(new FileOutputStream("JU_DelegateDAOTest.java"));
// innnerClassMtd = innerClass.getDeclaredMethod("marshal", new Class[] {DelegateDAO.Data.class, DataOutputStream.class });
// innnerClassMtd.invoke(obj, new Object[] {data, dos });
@@ -149,7 +149,7 @@ public class JU_DelegateDAO {
// DataInputStream dis = new DataInputStream(new FileInputStream("JU_DelegateDAOTest.java"));
// innnerClassMtd = innerClass.getDeclaredMethod("unmarshal", new Class[] {DelegateDAO.Data.class, DataInputStream.class });
// innnerClassMtd.invoke(obj, new Object[] {data, dis });
-
+
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -168,9 +168,9 @@ public class JU_DelegateDAO {
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- }
+ }
}
-
+
@Test
public void testData(){
DelegateDAO.Data data = new DelegateDAO.Data();
@@ -184,5 +184,5 @@ public class JU_DelegateDAO {
e.printStackTrace();
}
}
-
+
}
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_FutureDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_FutureDAO.java
index 07946156..f05738ea 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_FutureDAO.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_FutureDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -58,7 +58,7 @@ public class JU_FutureDAO {
AuthzTrans trans;
@Mock
Cluster cluster;
-
+
@Before
public void setUp() throws APIException, IOException {
initMocks(this);
@@ -72,13 +72,13 @@ public class JU_FutureDAO {
@Test
public void testReadByStartAndTarget() {
FutureDAO daoObj = new FutureDAO(trans, cluster, "test");
-
+
PSInfo psObj = Mockito.mock(PSInfo.class);
setPsByStartAndTarget(daoObj, psObj, "psByStartAndTarget");
-
+
Result<List<FutureDAO.Data>> rs1 = new Result<List<FutureDAO.Data>>(null,0,"test",new String[0]);
Mockito.doReturn(rs1).when(psObj).read(trans, "FutureDAO READ", new Object[]{"test"});
-
+
daoObj.readByStartAndTarget(trans,new Date(), "test");
}
@Test
@@ -91,7 +91,7 @@ public class JU_FutureDAO {
Result<ResultSet> rs1 = new Result<ResultSet>(null,0,"test",new String[0]);
Mockito.doReturn(rs1).when(psObj).exec(trans, "FutureDAOImpl CREATE", data);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
-
+
FutureDAOImpl daoObj=null;
try {
daoObj = new FutureDAOImpl(trans, historyDAO, psObj);
@@ -100,35 +100,35 @@ public class JU_FutureDAO {
e.printStackTrace();
}
Mockito.doReturn("test user").when(trans).user();
-
+
Result<FutureDAO.Data> retVal = daoObj.create(trans,data, "test");
assertTrue(retVal.status == 0);
-
+
StringBuilder sb = new StringBuilder(trans.user());
sb.append(data.target);
sb.append(System.currentTimeMillis());
data.id = UUID.nameUUIDFromBytes(sb.toString().getBytes());
-
+
rs1 = new Result<ResultSet>(null,1,"test",new String[0]);
Mockito.doReturn(rs1).when(psObj).exec(trans, "FutureDAOImpl CREATE", data);
-
+
retVal = daoObj.create(trans,data, "test");
assertTrue(retVal.status != 0);
-
-
+
+
}
-
+
public void setPsByStartAndTarget(FutureDAO FutureDAOObj, PSInfo psInfoObj, String fieldName) {
Field nsDaoField;
try {
nsDaoField = FutureDAO.class.getDeclaredField(fieldName);
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
nsDaoField.set(FutureDAOObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -141,7 +141,7 @@ public class JU_FutureDAO {
e.printStackTrace();
}
}
-
+
@Test
public void testWasMOdified() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -154,11 +154,11 @@ public class JU_FutureDAO {
Mockito.doNothing().when(tt).done();
FutureDAO.Data data = new FutureDAO.Data();
PSInfo createPS = Mockito.mock(PSInfo.class);
-
+
HistoryDAO historyDAO = Mockito.mock(HistoryDAO.class);
Result<ResultSet> rs1 = new Result<ResultSet>(null,0,"test",new String[0]);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
-
+
FutureDAOImpl daoObj = null;
try {
daoObj = new FutureDAOImpl(trans, historyDAO, createPS );
@@ -167,23 +167,23 @@ public class JU_FutureDAO {
e.printStackTrace();
}
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test"});
-
+
daoObj.wasModified(trans, CRUD.create, data, new String[] {});
daoObj.wasModified(trans, CRUD.create, data, new String[] {null});
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test",null});
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test","test"});
-
+
rs1 = new Result<ResultSet>(null,1,"test",new String[0]);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test","test"});
}
-
+
@Test
public void testSecondConstructor() {
HistoryDAO historyDAO = Mockito.mock(HistoryDAO.class);
FutureDAO daoObj = new FutureDAO(trans, historyDAO);
-
+
}
@Test
@@ -196,18 +196,18 @@ public class JU_FutureDAO {
break;
}
}
-
+
Constructor<?> constructor = innerClass.getDeclaredConstructors()[1];
constructor.setAccessible(true);
-
+
Constructor<?> constructor1 = innerClass.getDeclaredConstructors()[0];
constructor1.setAccessible(true);
try {
-
+
Object obj = constructor.newInstance(1);
obj = constructor1.newInstance();
Method innnerClassMtd;
-
+
FutureDAO.Data data = new FutureDAO.Data();
Row row = Mockito.mock(Row.class);
ByteBuffer bbObj = ByteBuffer.allocateDirect(10);
@@ -216,16 +216,16 @@ public class JU_FutureDAO {
bbObj.put(1, new Byte("1"));
bbObj.put(2, new Byte("2"));
Mockito.doReturn(bbObj).when(row).getBytesUnsafe(1);
-
+
innnerClassMtd = innerClass.getMethod("load", new Class[] {FutureDAO.Data.class, Row.class});
innnerClassMtd.invoke(obj, new Object[] {data, row});
-
+
innnerClassMtd = innerClass.getDeclaredMethod("key", new Class[] {FutureDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test"} });
-//
+//
innnerClassMtd = innerClass.getDeclaredMethod("body", new Class[] {FutureDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test","test","test","test","test","test","test","test","test"} });
-
+
// DataOutputStream dos = new DataOutputStream(new FileOutputStream("JU_FutureDAOTest.java"));
// innnerClassMtd = innerClass.getDeclaredMethod("marshal", new Class[] {FutureDAO.Data.class, DataOutputStream.class });
// innnerClassMtd.invoke(obj, new Object[] {data, dos });
@@ -233,7 +233,7 @@ public class JU_FutureDAO {
// DataInputStream dis = new DataInputStream(new FileInputStream("JU_FutureDAOTest.java"));
// innnerClassMtd = innerClass.getDeclaredMethod("unmarshal", new Class[] {FutureDAO.Data.class, DataInputStream.class });
// innnerClassMtd.invoke(obj, new Object[] {data, dis });
-
+
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -252,31 +252,31 @@ public class JU_FutureDAO {
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- }
+ }
}
-
+
}
class FutureDAOImpl extends FutureDAO{
-
+
public FutureDAOImpl(AuthzTrans trans, HistoryDAO historyDAO,PSInfo readPS ) throws APIException, IOException {
super(trans, historyDAO);
setPs(this, readPS, "createPS");
}
-
+
public void setPs(FutureDAOImpl FutureDAOObj, PSInfo psInfoObj, String methodName) {
Field nsDaoField;
try {
nsDaoField = CassDAOImpl.class.getDeclaredField(methodName);
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
nsDaoField.set(FutureDAOObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -289,5 +289,5 @@ class FutureDAOImpl extends FutureDAO{
e.printStackTrace();
}
}
-
+
}
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_HistoryDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_HistoryDAO.java
index f6d0a65b..3503adff 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_HistoryDAO.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_HistoryDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -61,7 +61,7 @@ public class JU_HistoryDAO {
AuthzTrans trans;
@Mock
Cluster cluster;
-
+
@Before
public void setUp() throws APIException, IOException {
initMocks(this);
@@ -77,7 +77,7 @@ public class JU_HistoryDAO {
HistoryDAO.Data data = daoObj.newInitedData();
assertTrue( Integer.toString(((new Date()).getYear())+1900).equalsIgnoreCase(Integer.toString(data.yr_mon).substring(0,4)) );
}
-
+
@Test
public void testCreateBatch() {
HistoryDAO daoObj = new HistoryDAO(trans, cluster, "test");
@@ -86,81 +86,81 @@ public class JU_HistoryDAO {
daoObj.createBatch(sb, data);
assertTrue(sb.toString().contains("INSERT INTO history"));
}
-
+
@Test
public void testReadByYYYYMM() {
HistoryDAO daoObj = new HistoryDAO(trans, cluster, "test");
AbsCassDAO<AuthzTrans, Data>.PSInfo psInfoObj = Mockito.mock(PSInfo.class);
setAbsCassDAO(daoObj, psInfoObj, "readByYRMN");
-
+
ResultSet rs = Mockito.mock(ResultSet.class);
Result<ResultSet> rs1 = new Result<ResultSet>(rs,0,"test",new String[0]);
Mockito.doReturn(rs1).when(psInfoObj).exec(trans, "yr_mon", 201905);
-
+
Result<List<Data>> retVal = daoObj.readByYYYYMM(trans, 201905);
assertTrue(retVal.status !=1);
-
+
rs1 = new Result<ResultSet>(rs,1,"test",new String[0]);
Mockito.doReturn(rs1).when(psInfoObj).exec(trans, "yr_mon", 201905);
retVal = daoObj.readByYYYYMM(trans, 201905);
assertTrue(retVal.status !=0);
}
-
+
@Test
public void testReadByUser() {
HistoryDAO daoObj = new HistoryDAO(trans, cluster, "test");
AbsCassDAO<AuthzTrans, Data>.PSInfo psInfoObj = Mockito.mock(PSInfo.class);
setAbsCassDAO(daoObj, psInfoObj, "readByUser");
-
+
ResultSet rs = Mockito.mock(ResultSet.class);
Result<ResultSet> rs1 = new Result<ResultSet>(rs,0,"test",new String[0]);
Mockito.doReturn(rs1).when(psInfoObj).exec(trans, "user", "test");
-
+
Result<List<Data>> retVal = daoObj.readByUser(trans, "test", 201905);
assertTrue(retVal.status !=1);
-
+
rs1 = new Result<ResultSet>(rs,1,"test",new String[0]);
Mockito.doReturn(rs1).when(psInfoObj).exec(trans, "user", "test");
retVal = daoObj.readByUser(trans,"test", 201905);
assertTrue(retVal.status !=0);
-
+
retVal = daoObj.readByUser(trans,"test");
assertTrue(retVal.status !=0);
}
-
+
@Test
public void testReadBySubject() {
HistoryDAO daoObj = new HistoryDAO(trans, cluster, "test");
AbsCassDAO<AuthzTrans, Data>.PSInfo psInfoObj = Mockito.mock(PSInfo.class);
setAbsCassDAO(daoObj, psInfoObj, "readBySubject");
-
+
ResultSet rs = Mockito.mock(ResultSet.class);
Result<ResultSet> rs1 = new Result<ResultSet>(rs,0,"test",new String[0]);
Mockito.doReturn(rs1).when(psInfoObj).exec(trans, "subject", "test", "test");
-
+
Result<List<Data>> retVal = daoObj.readBySubject(trans, "test", "test", 201905);
assertTrue(retVal.status !=1);
-
+
rs1 = new Result<ResultSet>(rs,1,"test",new String[0]);
Mockito.doReturn(rs1).when(psInfoObj).exec(trans, "subject", "test", "test");
retVal = daoObj.readBySubject(trans,"test", "test", 201905);
assertTrue(retVal.status !=0);
-
+
retVal = daoObj.readBySubject(trans,"test", "test");
assertTrue(retVal.status !=0);
}
-
+
public void setAbsCassDAO(HistoryDAO HistoryDAOObj, PSInfo psInfoObj, String fieldName) {
Field nsDaoField;
try {
nsDaoField = HistoryDAO.class.getDeclaredField(fieldName);
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
nsDaoField.set(HistoryDAOObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -173,14 +173,14 @@ public class JU_HistoryDAO {
e.printStackTrace();
}
}
-
-
+
+
@Test
public void testSecondConstructor() {
HistoryDAO historyDAO = Mockito.mock(HistoryDAO.class);
HistoryDAO daoObj = new HistoryDAO(trans, historyDAO);
-
+
}
@Test
@@ -193,14 +193,14 @@ public class JU_HistoryDAO {
break;
}
}
-
+
Constructor<?> constructor = innerClass.getDeclaredConstructors()[0];
constructor.setAccessible(true);
-
+
try {
Object obj = constructor.newInstance(1);
Method innnerClassMtd;
-
+
HistoryDAO.Data data = new HistoryDAO.Data();
Row row = Mockito.mock(Row.class);
ByteBuffer bbObj = ByteBuffer.allocateDirect(10);
@@ -209,16 +209,16 @@ public class JU_HistoryDAO {
bbObj.put(1, new Byte("1"));
bbObj.put(2, new Byte("2"));
Mockito.doReturn(bbObj).when(row).getBytesUnsafe(1);
-
+
innnerClassMtd = innerClass.getMethod("load", new Class[] {HistoryDAO.Data.class, Row.class});
innnerClassMtd.invoke(obj, new Object[] {data, row});
-
+
innnerClassMtd = innerClass.getDeclaredMethod("key", new Class[] {HistoryDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test"} });
-//
+//
innnerClassMtd = innerClass.getDeclaredMethod("body", new Class[] {HistoryDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test","test","test","test","test","test","test","test","test"} });
-
+
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -237,9 +237,9 @@ public class JU_HistoryDAO {
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- }
+ }
}
-
+
@Test
public void testYYYYMM(){
Class<?> innerClass = null;
@@ -250,14 +250,14 @@ public class JU_HistoryDAO {
break;
}
}
-
+
Constructor<?> constructor = innerClass.getDeclaredConstructors()[0];
constructor.setAccessible(true);
int yyyymm[] = new int[2];
try {
Object obj = constructor.newInstance(new HistoryDAO(trans, cluster, "test"), yyyymm);
Method innnerClassMtd;
-
+
HistoryDAO.Data data = new HistoryDAO.Data();
Row row = Mockito.mock(Row.class);
ByteBuffer bbObj = ByteBuffer.allocateDirect(10);
@@ -266,13 +266,13 @@ public class JU_HistoryDAO {
bbObj.put(1, new Byte("1"));
bbObj.put(2, new Byte("2"));
Mockito.doReturn(bbObj).when(row).getBytesUnsafe(1);
-
+
innnerClassMtd = innerClass.getMethod("ok", new Class[] {HistoryDAO.Data.class});
innnerClassMtd.invoke(obj, new Object[] {data});
-
+
data.yr_mon=201904;
innnerClassMtd.invoke(obj, new Object[] {data});
-
+
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -291,30 +291,30 @@ public class JU_HistoryDAO {
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- }
+ }
}
-
+
}
class HistoryDAOImpl extends HistoryDAO{
-
+
public HistoryDAOImpl(AuthzTrans trans, HistoryDAO historyDAO,PSInfo readPS ) throws APIException, IOException {
super(trans, historyDAO);
setPs(this, readPS, "createPS");
}
-
+
public void setPs(HistoryDAOImpl HistoryDAOObj, PSInfo psInfoObj, String methodName) {
Field nsDaoField;
try {
nsDaoField = CassDAOImpl.class.getDeclaredField(methodName);
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
nsDaoField.set(HistoryDAOObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -327,5 +327,5 @@ class HistoryDAOImpl extends HistoryDAO{
e.printStackTrace();
}
}
-
+
}
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_LocateDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_LocateDAO.java
index 53bad44e..d4f2c981 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_LocateDAO.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_LocateDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -60,7 +60,7 @@ public class JU_LocateDAO {
AuthzTrans trans;
@Mock
Cluster cluster;
-
+
@Before
public void setUp() throws APIException, IOException {
initMocks(this);
@@ -84,28 +84,28 @@ public class JU_LocateDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
PSInfo psObj = Mockito.mock(PSInfo.class);
setPsByStartAndTarget(daoObj, psObj, "psName");
-
+
Result<List<LocateDAO.Data>> rs1 = new Result<List<LocateDAO.Data>>(null,0,"test",new String[0]);
Mockito.doReturn(rs1).when(psObj).read(trans, "LocateDAO READ", new Object[]{"test"});
-
+
daoObj.readByName(trans, "test");
}
-
-
+
+
public void setPsByStartAndTarget(LocateDAO LocateDAOObj, PSInfo psInfoObj, String fieldName) {
Field nsDaoField;
try {
nsDaoField = LocateDAO.class.getDeclaredField(fieldName);
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
nsDaoField.set(LocateDAOObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -118,14 +118,14 @@ public class JU_LocateDAO {
e.printStackTrace();
}
}
-
+
@Test
public void testWasMOdified() {
-
+
LocateDAO.Data data = new LocateDAO.Data();
-
+
HistoryDAO historyDAO = Mockito.mock(HistoryDAO.class);
-
+
LocateDAO daoObj = null;
try {
daoObj = new LocateDAO(trans, historyDAO );
@@ -134,10 +134,10 @@ public class JU_LocateDAO {
e.printStackTrace();
}
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test"});
-
-
+
+
}
-
+
@Test
public void testSecondConstructor() {
AbsCassDAO historyDAO = Mockito.mock(AbsCassDAO.class);
@@ -148,7 +148,7 @@ public class JU_LocateDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
}
@Test
@@ -161,15 +161,15 @@ public class JU_LocateDAO {
break;
}
}
-
+
Constructor<?> constructor = innerClass.getDeclaredConstructors()[0];
constructor.setAccessible(true);
-
+
try {
-
+
Object obj = constructor.newInstance(1);
Method innnerClassMtd;
-
+
LocateDAO.Data data = new LocateDAO.Data();
Row row = Mockito.mock(Row.class);
ByteBuffer bbObj = ByteBuffer.allocateDirect(10);
@@ -178,16 +178,16 @@ public class JU_LocateDAO {
bbObj.put(1, new Byte("1"));
bbObj.put(2, new Byte("2"));
Mockito.doReturn(bbObj).when(row).getBytesUnsafe(1);
-
+
innnerClassMtd = innerClass.getMethod("load", new Class[] {LocateDAO.Data.class, Row.class});
innnerClassMtd.invoke(obj, new Object[] {data, row});
-
+
innnerClassMtd = innerClass.getDeclaredMethod("key", new Class[] {LocateDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 0, new Object[] {"test","test","test"} });
-
+
innnerClassMtd = innerClass.getDeclaredMethod("body", new Class[] {LocateDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test","test","test","test","test","test","test","test","test"} });
-
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
innnerClassMtd = innerClass.getDeclaredMethod("marshal", new Class[] {LocateDAO.Data.class, DataOutputStream.class });
@@ -197,7 +197,7 @@ public class JU_LocateDAO {
DataInputStream dis = new DataInputStream(bais);
innnerClassMtd = innerClass.getDeclaredMethod("unmarshal", new Class[] {LocateDAO.Data.class, DataInputStream.class });
innnerClassMtd.invoke(obj, new Object[] {data, dis });
-
+
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -216,9 +216,9 @@ public class JU_LocateDAO {
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- }
+ }
}
-
+
@Test
public void testData(){
LocateDAO.Data data = new LocateDAO.Data();
@@ -230,16 +230,16 @@ public class JU_LocateDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
data.subprotocol(true);
-
+
Set<String> subProt = new HashSet<String>();
Field protField;
try {
protField = LocateDAO.Data.class.getDeclaredField("subprotocol");
-
+
protField.setAccessible(true);
-
+
protField.set(data, subProt);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -251,15 +251,15 @@ public class JU_LocateDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
data.subprotocol(true);
subProt = new TreeSet<String>();
subProt.add("test");
try {
protField = LocateDAO.Data.class.getDeclaredField("subprotocol");
-
+
protField.setAccessible(true);
-
+
protField.set(data, subProt);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -271,36 +271,36 @@ public class JU_LocateDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
data.subprotocol(true);
data.subprotocol(false);
-
+
LocateDAO.Data newDate = data.copy();
assertTrue(data.name.equals(newDate.name));
}
-
+
}
class LocateDAOImpl extends LocateDAO{
-
+
public LocateDAOImpl(AuthzTrans trans, HistoryDAO historyDAO,PSInfo readPS ) throws APIException, IOException {
super(trans, historyDAO);
setPs(this, readPS, "createPS");
}
-
+
public void setPs(LocateDAOImpl LocateDAOObj, PSInfo psInfoObj, String methodName) {
Field nsDaoField;
try {
nsDaoField = CassDAOImpl.class.getDeclaredField(methodName);
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
nsDaoField.set(LocateDAOObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -313,5 +313,5 @@ class LocateDAOImpl extends LocateDAO{
e.printStackTrace();
}
}
-
+
}
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_Namespace.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_Namespace.java
index 6bdb3d76..e1c13999 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_Namespace.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_Namespace.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -38,7 +38,7 @@ import org.onap.aaf.misc.env.APIException;
public class JU_Namespace {
Namespace namespace;
-
+
@Before
public void setUp() throws APIException, IOException {
initMocks(this);
@@ -56,9 +56,9 @@ public class JU_Namespace {
data.attrib.put("test", "test");
namespace = new Namespace(data);
}
-
-
-
+
+
+
@Test
public void testSecondConstructor() {
@@ -72,10 +72,10 @@ public class JU_Namespace {
namespace = new Namespace(data,owner, admin);
data.attrib.put("test", "test");
namespace = new Namespace(data ,owner, admin);
-
+
NsDAO.Data retData = namespace.data();
assertTrue(retData.name.equals("name"));
-
+
}
@Test
public void testBytify() {
@@ -101,5 +101,5 @@ public class JU_Namespace {
nameObj = new Namespace(data);
assertTrue(namespace.equals(nameObj));
}
-
+
} \ No newline at end of file
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_NsDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_NsDAO.java
index 9be4f5a2..3923d7e4 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_NsDAO.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_NsDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -76,7 +76,7 @@ public class JU_NsDAO {
Session session;
@Mock
ResultSet rs;
-
+
@Before
public void setUp() throws APIException, IOException {
initMocks(this);
@@ -105,18 +105,18 @@ public class JU_NsDAO {
e.printStackTrace();
}
}
-
+
public void setPsByStartAndTarget(NsDAO NsDAOObj, PSInfo psInfoObj, String fieldName) {
Field nsDaoField;
try {
nsDaoField = NsDAO.class.getDeclaredField(fieldName);
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
nsDaoField.set(NsDAOObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -129,7 +129,7 @@ public class JU_NsDAO {
e.printStackTrace();
}
}
-
+
@Test
public void testWasMOdified() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -141,13 +141,13 @@ public class JU_NsDAO {
Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).error();
Mockito.doNothing().when(tt).done();
NsDAO.Data data = new NsDAO.Data();
-
+
HistoryDAO historyDAO = Mockito.mock(HistoryDAO.class);
Result<ResultSet> rs1 = new Result<ResultSet>(null,0,"test",new Object[0]);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
CacheInfoDAO cacheInfoDAO = Mockito.mock(CacheInfoDAO.class);
Mockito.doReturn(rs1).when(cacheInfoDAO).touch(Mockito.any(), Mockito.anyString(), Mockito.anyInt());
-
+
NsDAO daoObj = null;
try {
daoObj = new NsDAO(trans, historyDAO, cacheInfoDAO);
@@ -156,17 +156,17 @@ public class JU_NsDAO {
e.printStackTrace();
}
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test"});
-
+
daoObj.wasModified(trans, CRUD.create, data, new String[] {});
daoObj.wasModified(trans, CRUD.create, data, new String[] {null});
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test",null});
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test","test"});
-
+
rs1 = new Result<ResultSet>(null,1,"test",new Object[0]);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test","test"});
}
-
+
@Test
public void testSecondConstructor() {
HistoryDAO historyDAO = Mockito.mock(HistoryDAO.class);
@@ -178,7 +178,7 @@ public class JU_NsDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
}
@Test
@@ -191,15 +191,15 @@ public class JU_NsDAO {
break;
}
}
-
+
Constructor<?> constructor = innerClass.getDeclaredConstructors()[0];
constructor.setAccessible(true);
-
+
try {
-
+
Object obj = constructor.newInstance(1);
Method innnerClassMtd;
-
+
NsDAO.Data data = new NsDAO.Data();
Row row = Mockito.mock(Row.class);
ByteBuffer bbObj = ByteBuffer.allocateDirect(10);
@@ -208,16 +208,16 @@ public class JU_NsDAO {
bbObj.put(1, new Byte("1"));
bbObj.put(2, new Byte("2"));
Mockito.doReturn(bbObj).when(row).getBytesUnsafe(1);
-
+
innnerClassMtd = innerClass.getMethod("load", new Class[] {NsDAO.Data.class, Row.class});
innnerClassMtd.invoke(obj, new Object[] {data, row});
-
+
innnerClassMtd = innerClass.getDeclaredMethod("key", new Class[] {NsDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test"} });
-//
+//
innnerClassMtd = innerClass.getDeclaredMethod("body", new Class[] {NsDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test","test","test","test","test","test","test","test","test"} });
-
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
innnerClassMtd = innerClass.getDeclaredMethod("marshal", new Class[] {NsDAO.Data.class, DataOutputStream.class });
@@ -227,7 +227,7 @@ public class JU_NsDAO {
DataInputStream dis = new DataInputStream(bais);
innnerClassMtd = innerClass.getDeclaredMethod("unmarshal", new Class[] {NsDAO.Data.class, DataInputStream.class });
innnerClassMtd.invoke(obj, new Object[] {data, dis });
-
+
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -246,7 +246,7 @@ public class JU_NsDAO {
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- }
+ }
}
@Test
public void testCreate() {
@@ -267,7 +267,7 @@ public class JU_NsDAO {
e.printStackTrace();
}
Mockito.doReturn("test user").when(trans).user();
-
+
Result<NsDAO.Data> retVal = daoObj.create(trans,data);
assertTrue(retVal.status == 4);
@@ -278,7 +278,7 @@ public class JU_NsDAO {
data.parent = "parent";
data.attrib = new HashMap<>();
data.attrib.put("test", "test");
-
+
Field cbField;
Mockito.doReturn(rs1).when(cacheInfoDAO).touch(Mockito.any(), Mockito.anyString(), Mockito.anyInt());
try {
@@ -295,10 +295,10 @@ public class JU_NsDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
retVal = daoObj.create(trans,data);
assertTrue(retVal.status == 9);
-
+
Field owningField;
Mockito.doReturn(rs1).when(cacheInfoDAO).touch(Mockito.any(), Mockito.anyString(), Mockito.anyInt());
try {
@@ -317,9 +317,9 @@ public class JU_NsDAO {
}
retVal = daoObj.create(trans,data);
assertTrue(retVal.status == 0);
-
+
}
-
+
@Test
public void testUpdate() {
PSInfo psObj = Mockito.mock(PSInfo.class);
@@ -340,7 +340,7 @@ public class JU_NsDAO {
e.printStackTrace();
}
Mockito.doReturn("test user").when(trans).user();
-
+
Result<Void> retVal = daoObj.update(trans,data);
assertTrue(retVal.status == 4);
@@ -367,10 +367,10 @@ public class JU_NsDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
retVal = daoObj.update(trans,data);
assertTrue(retVal.status == 0);
-
+
ResultSet rsMock = Mockito.mock(ResultSet.class);
Iterator<Row> iteMock = Mockito.mock(Iterator.class);
Mockito.doReturn(iteMock).when(rsMock).iterator();
@@ -382,7 +382,7 @@ public class JU_NsDAO {
retVal = daoObj.update(trans,data);
assertTrue(retVal.status == 0);
}
-
+
@Test
public void testRead() {
PSInfo psObj = Mockito.mock(PSInfo.class);
@@ -408,7 +408,7 @@ public class JU_NsDAO {
e.printStackTrace();
}
Mockito.doReturn("test user").when(trans).user();
-
+
Result<List<Data>> retVal = daoObj.read(trans,data);
assertTrue(retVal.status == 0);
@@ -436,7 +436,7 @@ public class JU_NsDAO {
assertTrue(retVal.status == 0);
}
-
+
@Test
public void testReadByObject() {
PSInfo psObj = Mockito.mock(PSInfo.class);
@@ -462,7 +462,7 @@ public class JU_NsDAO {
e.printStackTrace();
}
Mockito.doReturn("test user").when(trans).user();
-
+
Result<List<Data>> retVal = daoObj.read(trans,new Object[] {});
assertTrue(retVal.status == 0);
@@ -490,7 +490,7 @@ public class JU_NsDAO {
assertTrue(retVal.status == 0);
}
-
+
@Test
public void testDelete() {
PSInfo psObj = Mockito.mock(PSInfo.class);
@@ -533,7 +533,7 @@ public class JU_NsDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
Result<Void> retVal = daoObj.delete(trans,data, false);
assertTrue(retVal.status == 0);
@@ -541,12 +541,12 @@ public class JU_NsDAO {
dataAL.add(data);
rs1 = new Result<List<Data>>(dataAL,0,"test",new Object[0]);
Mockito.doReturn(rs1).when(psObj).read(trans, "NsDAOImpl READ", data);
-
+
retVal = daoObj.delete(trans,data, false);
assertTrue(retVal.status == 0);
}
-
+
@Test
public void testReadNsByAttrib() {
PSInfo psObj = Mockito.mock(PSInfo.class);
@@ -560,7 +560,7 @@ public class JU_NsDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_PORT,"100");
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_PORT,"9042");
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_USER_NAME,"100");
@@ -572,7 +572,7 @@ public class JU_NsDAO {
Mockito.doReturn(rs1).when(psObj).read(trans, "NsDAOImpl READ", data);
Mockito.doReturn(rs1).when(psObj).exec(trans, "NsDAOImpl DELETE", data);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
-
+
Mockito.doReturn("test user").when(trans).user();
Field cbField;
try {
@@ -589,10 +589,10 @@ public class JU_NsDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
Result<Set<String>> retVal = daoObj.readNsByAttrib(trans,"test");
assertTrue(retVal.status == 0);
-
+
ResultSet rsMock = Mockito.mock(ResultSet.class);
Iterator<Row> iteMock = Mockito.mock(Iterator.class);
Mockito.doReturn(iteMock).when(rsMock).iterator();
@@ -619,7 +619,7 @@ public class JU_NsDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_PORT,"100");
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_PORT,"9042");
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_USER_NAME,"100");
@@ -631,7 +631,7 @@ public class JU_NsDAO {
Mockito.doReturn(rs1).when(psObj).read(trans, "NsDAOImpl READ", data);
Mockito.doReturn(rs1).when(psObj).exec(trans, "NsDAOImpl DELETE", data);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
-
+
Mockito.doReturn("test user").when(trans).user();
Field cbField;
try {
@@ -648,11 +648,11 @@ public class JU_NsDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
Result<Void> retVal = daoObj.attribAdd(trans, "test", "test", "test");
assertTrue(retVal.status == 0);
}
-
+
@Test
public void testAttribRemove() {
PSInfo psObj = Mockito.mock(PSInfo.class);
@@ -666,7 +666,7 @@ public class JU_NsDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_PORT,"100");
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_PORT,"9042");
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_USER_NAME,"100");
@@ -678,7 +678,7 @@ public class JU_NsDAO {
Mockito.doReturn(rs1).when(psObj).read(trans, "NsDAOImpl READ", data);
Mockito.doReturn(rs1).when(psObj).exec(trans, "NsDAOImpl DELETE", data);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
-
+
Mockito.doReturn("test user").when(trans).user();
Field cbField;
try {
@@ -695,11 +695,11 @@ public class JU_NsDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
Result<Void> retVal = daoObj.attribRemove(trans, "test", "test");
assertTrue(retVal.status == 0);
}
-
+
@Test
public void testAddDescription() {
PSInfo psObj = Mockito.mock(PSInfo.class);
@@ -713,7 +713,7 @@ public class JU_NsDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_PORT,"100");
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_PORT,"9042");
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_USER_NAME,"100");
@@ -744,11 +744,11 @@ public class JU_NsDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
Result<Void> retVal = daoObj.addDescription(trans, "test", "test");
assertTrue(retVal.status == 0);
}
-
+
@Test
public void testGetChildren() {
PSInfo psObj = Mockito.mock(PSInfo.class);
@@ -761,11 +761,11 @@ public class JU_NsDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
Result<List<Data>> retVal = daoObj.getChildren(trans, "test");
assertNull(retVal);
}
-
+
@Test
public void testData() {
NsDAO.Data data = new NsDAO.Data();
@@ -778,10 +778,10 @@ public class JU_NsDAO {
data.attrib(false);
data.attrib = new ConcurrentHashMap<>();
data.attrib(true);
-
+
data.name="123";
data.split("test");
-
+
data.toString();
}
@@ -789,12 +789,12 @@ public class JU_NsDAO {
class NsDAOImpl extends NsDAO{
-
+
// public NsDAOImpl(AuthzTrans trans, HistoryDAO historyDAO,PSInfo readPS ) throws APIException, IOException {
// super(trans, historyDAO);
// setSession(this, Mockito.mock(Session.class));
// }
-
+
public NsDAOImpl(AuthzTrans trans, Cluster cluster, String keySpace, Session session)throws APIException, IOException {
super(trans, cluster, keySpace);
@@ -816,13 +816,13 @@ class NsDAOImpl extends NsDAO{
Field nsDaoField;
try {
nsDaoField = NsDAO.class.getDeclaredField(methodName);
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
nsDaoField.set(NsDAOObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -840,13 +840,13 @@ class NsDAOImpl extends NsDAO{
Field nsDaoField;
try {
nsDaoField = CassDAOImpl.class.getDeclaredField(methodName);
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
nsDaoField.set(NsDAOObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -863,13 +863,13 @@ class NsDAOImpl extends NsDAO{
Field nsDaoField;
try {
nsDaoField = AbsCassDAO.class.getDeclaredField("session");
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
nsDaoField.set(approvalDaoObj, session);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_OAuthTokenDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_OAuthTokenDAO.java
index 5c158b6a..93c595d4 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_OAuthTokenDAO.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_OAuthTokenDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -63,7 +63,7 @@ public class JU_OAuthTokenDAO {
AuthzTrans trans;
@Mock
Cluster cluster;
-
+
@Before
public void setUp() throws APIException, IOException {
initMocks(this);
@@ -77,27 +77,27 @@ public class JU_OAuthTokenDAO {
@Test
public void testReadByUser() {
OAuthTokenDAO daoObj = new OAuthTokenDAO(trans, cluster, "test");
-
+
PSInfo psObj = Mockito.mock(PSInfo.class);
setPsByStartAndTarget(daoObj, psObj, "psByUser");
-
+
Result<List<OAuthTokenDAO.Data>> rs1 = new Result<List<OAuthTokenDAO.Data>>(null,0,"test",new String[0]);
Mockito.doReturn(rs1).when(psObj).read(trans, "OAuthTokenDAO READ", new Object[]{"test"});
-
+
daoObj.readByUser(trans, "test");
}
-
+
public void setPsByStartAndTarget(OAuthTokenDAO OAuthTokenDAOObj, PSInfo psInfoObj, String fieldName) {
Field nsDaoField;
try {
nsDaoField = OAuthTokenDAO.class.getDeclaredField(fieldName);
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
nsDaoField.set(OAuthTokenDAOObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -110,7 +110,7 @@ public class JU_OAuthTokenDAO {
e.printStackTrace();
}
}
-
+
@Test
public void testWasMOdified() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -126,15 +126,15 @@ public class JU_OAuthTokenDAO {
OAuthTokenDAO daoObj = null;
daoObj = new OAuthTokenDAO(trans, cluster, "test" );
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test"});
-
+
}
-
+
@Test
public void testSecondConstructor() {
AbsCassDAO absCassDAO = Mockito.mock(AbsCassDAO.class);
OAuthTokenDAO daoObj = new OAuthTokenDAO(trans, absCassDAO);
-
+
}
@Test
@@ -149,15 +149,15 @@ public class JU_OAuthTokenDAO {
data.scopes(false);
data.scopes = new ConcurrentHashSet<>();
data.scopes(true);
-
+
data.expires = new Date();
data.user="test";
data.id="id";
data.toString();
-
+
data.active=true;
data.toString();
-
+
try {
ByteBuffer bb = data.bytify();
data.reconstitute(bb);
@@ -176,15 +176,15 @@ public class JU_OAuthTokenDAO {
break;
}
}
-
+
Constructor<?> constructor = innerClass.getDeclaredConstructors()[0];
constructor.setAccessible(true);
-
+
try {
-
+
Object obj = constructor.newInstance(1);
Method innnerClassMtd;
-
+
OAuthTokenDAO.Data data = new OAuthTokenDAO.Data();
Row row = Mockito.mock(Row.class);
ByteBuffer bbObj = ByteBuffer.allocateDirect(10);
@@ -193,16 +193,16 @@ public class JU_OAuthTokenDAO {
bbObj.put(1, new Byte("1"));
bbObj.put(2, new Byte("2"));
Mockito.doReturn(bbObj).when(row).getBytesUnsafe(1);
-
+
innnerClassMtd = innerClass.getMethod("load", new Class[] {OAuthTokenDAO.Data.class, Row.class});
innnerClassMtd.invoke(obj, new Object[] {data, row});
-
+
innnerClassMtd = innerClass.getDeclaredMethod("key", new Class[] {OAuthTokenDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test"} });
-//
+//
innnerClassMtd = innerClass.getDeclaredMethod("body", new Class[] {OAuthTokenDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test","test","test","test","test","test","test","test","test","test"} });
-
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
innnerClassMtd = innerClass.getDeclaredMethod("marshal", new Class[] {OAuthTokenDAO.Data.class, DataOutputStream.class });
@@ -212,7 +212,7 @@ public class JU_OAuthTokenDAO {
DataInputStream dis = new DataInputStream(bais);
innnerClassMtd = innerClass.getDeclaredMethod("unmarshal", new Class[] {OAuthTokenDAO.Data.class, DataInputStream.class });
innnerClassMtd.invoke(obj, new Object[] {data, dis });
-
+
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -231,31 +231,31 @@ public class JU_OAuthTokenDAO {
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- }
+ }
}
-
+
}
class OAuthTokenDAOImpl extends OAuthTokenDAO{
-
+
public OAuthTokenDAOImpl(AuthzTrans trans, HistoryDAO historyDAO,PSInfo readPS ) throws APIException, IOException {
super(trans, historyDAO);
setPs(this, readPS, "createPS");
}
-
+
public void setPs(OAuthTokenDAOImpl OAuthTokenDAOObj, PSInfo psInfoObj, String methodName) {
Field nsDaoField;
try {
nsDaoField = CassDAOImpl.class.getDeclaredField(methodName);
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
nsDaoField.set(OAuthTokenDAOObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -268,5 +268,5 @@ class OAuthTokenDAOImpl extends OAuthTokenDAO{
e.printStackTrace();
}
}
-
+
}
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_PermDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_PermDAO.java
index 57f39922..28f92890 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_PermDAO.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_PermDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -69,7 +69,7 @@ public class JU_PermDAO {
Cluster cluster;
@Mock
Session session;
-
+
@Before
public void setUp() throws APIException, IOException {
initMocks(this);
@@ -114,13 +114,13 @@ public class JU_PermDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
PSInfo psObj = Mockito.mock(PSInfo.class);
setPsByStartAndTarget(daoObj, psObj, "psByType");
-
+
Result<List<PermDAO.Data>> rs1 = new Result<List<PermDAO.Data>>(null,0,"test",new String[0]);
Mockito.doReturn(rs1).when(psObj).read(trans, "PermDAO READ", new Object[]{"test"});
-
+
daoObj.readByType(trans, "test", "test");
}
@Test
@@ -138,13 +138,13 @@ public class JU_PermDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
PSInfo psObj = Mockito.mock(PSInfo.class);
setPsByStartAndTarget(daoObj, psObj, "psChildren");
-
+
Result<List<PermDAO.Data>> rs1 = new Result<List<PermDAO.Data>>(null,0,"test",new String[0]);
Mockito.doReturn(rs1).when(psObj).read(trans, "PermDAO READ", new Object[]{"test"});
-
+
daoObj.readChildren(trans, "test", "test");
}
@Test
@@ -162,13 +162,13 @@ public class JU_PermDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
PSInfo psObj = Mockito.mock(PSInfo.class);
setPsByStartAndTarget(daoObj, psObj, "psNS");
-
+
Result<List<PermDAO.Data>> rs1 = new Result<List<PermDAO.Data>>(null,0,"test",new String[0]);
Mockito.doReturn(rs1).when(psObj).read(trans, "PermDAO READ", new Object[]{"test"});
-
+
daoObj.readNS(trans, "test");
}
@Test
@@ -190,7 +190,7 @@ public class JU_PermDAO {
Mockito.doReturn(tt).when(trans).start("Clear Reset Deque", Env.SUB);
Mockito.doReturn(tt).when(trans).start("New Cassandra Session", Env.SUB);
Mockito.doReturn(tt).when(trans).start("Preparing PSInfo CREATE on PermDAO", Env.SUB);
-
+
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_PORT,"100");
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_PORT,"9042");
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_USER_NAME,"100");
@@ -202,10 +202,10 @@ public class JU_PermDAO {
Mockito.doReturn(rs1).when(psObj).read(trans, "PermDAOImpl READ", data);
Mockito.doReturn(rs1).when(psObj).exec(trans, "PermDAOImpl DELETE", data);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
-
+
Result<Void> rs2 = new Result<Void>(null,0,"test",new String[0]);
Mockito.doReturn(rs2).when(cacheInfoDAO).touch(Mockito.any(AuthzTrans.class),Mockito.anyString(), Mockito.anyVararg());
-
+
rs1 = new Result<List<Data>>(null,1,"test",new String[0]);
Mockito.doReturn(rs1).when(cacheInfoDAO).touch(Mockito.any(), Mockito.anyString(), Mockito.anyInt());
Mockito.doReturn("test user").when(trans).user();
@@ -224,11 +224,11 @@ public class JU_PermDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
PermDAO.Data perm = new PermDAO.Data();
Result<Void> retVal = daoObj.addRole(trans, perm, "test");
assertTrue(retVal.status == 9);
-
+
Field owningField;
try {
owningField = AbsCassDAO.class.getDeclaredField("owningDAO");
@@ -247,7 +247,7 @@ public class JU_PermDAO {
retVal = daoObj.addRole(trans, perm, "test");
assertTrue(retVal.status == 0);
}
-
+
@Test
public void testDelRole() {
PSInfo psObj = Mockito.mock(PSInfo.class);
@@ -267,7 +267,7 @@ public class JU_PermDAO {
Mockito.doReturn(tt).when(trans).start("Clear Reset Deque", Env.SUB);
Mockito.doReturn(tt).when(trans).start("New Cassandra Session", Env.SUB);
Mockito.doReturn(tt).when(trans).start("Preparing PSInfo CREATE on PermDAO", Env.SUB);
-
+
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_PORT,"100");
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_PORT,"9042");
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_USER_NAME,"100");
@@ -279,14 +279,14 @@ public class JU_PermDAO {
Mockito.doReturn(rs1).when(psObj).read(trans, "PermDAOImpl READ", data);
Mockito.doReturn(rs1).when(psObj).exec(trans, "PermDAOImpl DELETE", data);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
-
+
Result<Void> rs2 = new Result<Void>(null,0,"test",new String[0]);
Mockito.doReturn(rs2).when(cacheInfoDAO).touch(Mockito.any(AuthzTrans.class),Mockito.anyString(), Mockito.anyVararg());
-
+
rs1 = new Result<List<Data>>(null,1,"test",new String[0]);
Mockito.doReturn(rs1).when(cacheInfoDAO).touch(Mockito.any(), Mockito.anyString(), Mockito.anyInt());
Mockito.doReturn("test user").when(trans).user();
-
+
PermDAO.Data perm = new PermDAO.Data();
Field cbField;
try {
@@ -303,10 +303,10 @@ public class JU_PermDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
Result<Void> retVal = daoObj.delRole(trans, perm, "test");
assertTrue(retVal.status == 9);
-
+
Field owningDaoField;
try {
owningDaoField = AbsCassDAO.class.getDeclaredField("owningDAO");
@@ -325,7 +325,7 @@ public class JU_PermDAO {
retVal = daoObj.delRole(trans, perm, "test");
assertTrue(retVal.status == 0);
}
-
+
@Test
public void testAddDescription() {
PSInfo psObj = Mockito.mock(PSInfo.class);
@@ -345,7 +345,7 @@ public class JU_PermDAO {
Mockito.doReturn(tt).when(trans).start("Clear Reset Deque", Env.SUB);
Mockito.doReturn(tt).when(trans).start("New Cassandra Session", Env.SUB);
Mockito.doReturn(tt).when(trans).start("Preparing PSInfo CREATE on PermDAO", Env.SUB);
-
+
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_PORT,"100");
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_PORT,"9042");
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_USER_NAME,"100");
@@ -357,14 +357,14 @@ public class JU_PermDAO {
Mockito.doReturn(rs1).when(psObj).read(trans, "PermDAOImpl READ", data);
Mockito.doReturn(rs1).when(psObj).exec(trans, "PermDAOImpl DELETE", data);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
-
+
Result<Void> rs2 = new Result<Void>(null,1,"test",new String[0]);
Mockito.doReturn(rs2).when(cacheInfoDAO).touch(Mockito.any(AuthzTrans.class),Mockito.anyString(), Mockito.anyVararg());
-
+
rs1 = new Result<List<Data>>(null,1,"test",new String[0]);
Mockito.doReturn(rs1).when(cacheInfoDAO).touch(Mockito.any(), Mockito.anyString(), Mockito.anyInt());
Mockito.doReturn("test user").when(trans).user();
-
+
PermDAO.Data perm = new PermDAO.Data();
Field cbField;
try {
@@ -381,10 +381,10 @@ public class JU_PermDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
Result<Void> retVal = daoObj.addDescription(trans, "test", "test", "test", "test", "test");
assertTrue(retVal.status == 9);
-
+
Field owningDaoField;
try {
owningDaoField = AbsCassDAO.class.getDeclaredField("owningDAO");
@@ -403,18 +403,18 @@ public class JU_PermDAO {
retVal = daoObj.addDescription(trans, "test", "test", "test", "test", "test");
assertTrue(retVal.status == 0);
}
-
+
public void setPsByStartAndTarget(PermDAO PermDAOObj, PSInfo psInfoObj, String fieldName) {
Field PermDAOField;
try {
PermDAOField = PermDAO.class.getDeclaredField(fieldName);
-
+
PermDAOField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(PermDAOField, PermDAOField.getModifiers() & ~Modifier.FINAL);
-
+
PermDAOField.set(PermDAOObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -427,7 +427,7 @@ public class JU_PermDAO {
e.printStackTrace();
}
}
-
+
@Test
public void testWasMOdified() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -440,15 +440,15 @@ public class JU_PermDAO {
Mockito.doNothing().when(tt).done();
PermDAO.Data data = new PermDAO.Data();
PSInfo createPS = Mockito.mock(PSInfo.class);
-
+
HistoryDAO historyDAO = Mockito.mock(HistoryDAO.class);
Result<ResultSet> rs1 = new Result<ResultSet>(null,0,"test",new String[0]);
Result<Void> rs2 = new Result<Void>(null,0,"test",new String[0]);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
-
+
CacheInfoDAO cacheInfoDAO = Mockito.mock(CacheInfoDAO.class);
Mockito.doReturn(rs2).when(cacheInfoDAO).touch(Mockito.any(AuthzTrans.class),Mockito.anyString(), Mockito.anyVararg());
-
+
PermDAOImpl daoObj = null;
try {
daoObj = new PermDAOImpl(trans, historyDAO, cacheInfoDAO, createPS );
@@ -457,24 +457,24 @@ public class JU_PermDAO {
e.printStackTrace();
}
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test"});
-
+
daoObj.wasModified(trans, CRUD.create, data, new String[] {});
daoObj.wasModified(trans, CRUD.create, data, new String[] {null});
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test",null});
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test","test"});
-
+
rs1 = new Result<ResultSet>(null,1,"test",new String[0]);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
daoObj.wasModified(trans, CRUD.delete, data, new String[] {"test","test"});
}
-
+
@Test
public void testSecondConstructor() {
HistoryDAO historyDAO = Mockito.mock(HistoryDAO.class);
CacheInfoDAO cacheInfoDAO = Mockito.mock(CacheInfoDAO.class);
PermDAO daoObj = new PermDAO(trans, historyDAO, cacheInfoDAO);
-
+
}
@Test
@@ -487,15 +487,15 @@ public class JU_PermDAO {
break;
}
}
-
+
Constructor<?> constructor = innerClass.getDeclaredConstructors()[0];
constructor.setAccessible(true);
-
+
try {
-
+
Object obj = constructor.newInstance(1);
Method innnerClassMtd;
-
+
PermDAO.Data data = new PermDAO.Data();
Row row = Mockito.mock(Row.class);
ByteBuffer bbObj = ByteBuffer.allocateDirect(10);
@@ -504,16 +504,16 @@ public class JU_PermDAO {
bbObj.put(1, new Byte("1"));
bbObj.put(2, new Byte("2"));
Mockito.doReturn(bbObj).when(row).getBytesUnsafe(1);
-
+
innnerClassMtd = innerClass.getMethod("load", new Class[] {PermDAO.Data.class, Row.class});
innnerClassMtd.invoke(obj, new Object[] {data, row});
-
+
innnerClassMtd = innerClass.getDeclaredMethod("key", new Class[] {PermDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test","test","test"} });
-//
+//
innnerClassMtd = innerClass.getDeclaredMethod("body", new Class[] {PermDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test","test","test","test","test","test","test","test","test"} });
-
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
innnerClassMtd = innerClass.getDeclaredMethod("marshal", new Class[] {PermDAO.Data.class, DataOutputStream.class });
@@ -523,7 +523,7 @@ public class JU_PermDAO {
DataInputStream dis = new DataInputStream(bais);
innnerClassMtd = innerClass.getDeclaredMethod("unmarshal", new Class[] {PermDAO.Data.class, DataInputStream.class });
innnerClassMtd.invoke(obj, new Object[] {data, dis });
-
+
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -542,21 +542,21 @@ public class JU_PermDAO {
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- }
+ }
}
-
+
@Test
public void testData() {
PermDAO.Data data = new PermDAO.Data();
NsSplit nss = new NsSplit("test", "test");
data = new PermDAO.Data(nss, "test", "test");
-
+
data.toString();
-
+
assertTrue("test.test|test|test".equalsIgnoreCase(data.fullPerm()));
-
+
Question q = Mockito.mock( Question.class);
-
+
Result<NsSplit> rs = new Result<NsSplit>(nss,0,"test",new Object[0]);
Mockito.doReturn(rs).when(q).deriveNsSplit(trans, "test");
Result<Data> retVal= PermDAO.Data.decode(trans, q, "test|||");
@@ -566,7 +566,7 @@ public class JU_PermDAO {
retVal= PermDAO.Data.decode(trans, q, "test||");
retVal1= PermDAO.Data.decodeToArray(trans, q, "test||");
assertTrue(retVal.status==0);
-
+
rs = new Result<NsSplit>(nss,1,"test",new Object[0]);
Mockito.doReturn(rs).when(q).deriveNsSplit(trans, "test");
retVal= PermDAO.Data.decode(trans, q, "test||");
@@ -576,7 +576,7 @@ public class JU_PermDAO {
retVal= PermDAO.Data.decode(trans, q, "test|");
retVal1= PermDAO.Data.decodeToArray(trans, q, "test|");
assertTrue(retVal.status==4);
-
+
NsDAO.Data ns = new NsDAO.Data();
ns.name="test";
PermDAO.Data.create(ns, "test");
@@ -586,7 +586,7 @@ public class JU_PermDAO {
Mockito.doReturn(rs).when(q).deriveNsSplit(trans, "test");
PermDAO.Data.create(trans,q, "test|test|test|test");
}
-
+
}
class PermDAOImpl extends PermDAO{
@@ -594,25 +594,25 @@ class PermDAOImpl extends PermDAO{
super(trans, historyDAO, cacheDao);
setPs(this, readPS, "createPS");
}
-
+
public PermDAOImpl(AuthzTrans trans, HistoryDAO historyDAO,CacheInfoDAO cacheDao, PSInfo readPS, Session session ) throws APIException, IOException {
super(trans, historyDAO, cacheDao);
setPs(this, readPS, "createPS");
setSession(this, session);
}
-
+
public void setPs(PermDAOImpl PermDAOObj, PSInfo psInfoObj, String methodName) {
Field PermDAOField;
try {
PermDAOField = CassDAOImpl.class.getDeclaredField(methodName);
-
+
PermDAOField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(PermDAOField, PermDAOField.getModifiers() & ~Modifier.FINAL);
-
+
PermDAOField.set(PermDAOObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -625,18 +625,18 @@ class PermDAOImpl extends PermDAO{
e.printStackTrace();
}
}
-
+
public void setSession(PermDAOImpl approvalDaoObj, Session session) {
Field nsDaoField;
try {
nsDaoField = AbsCassDAO.class.getDeclaredField("session");
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
nsDaoField.set(approvalDaoObj, session);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_RoleDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_RoleDAO.java
index 4057a6ed..f91fac44 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_RoleDAO.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_RoleDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -70,7 +70,7 @@ public class JU_RoleDAO {
Cluster cluster;
@Mock
Session session;
-
+
@Before
public void setUp() throws APIException, IOException {
initMocks(this);
@@ -113,13 +113,13 @@ public class JU_RoleDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
PSInfo psObj = Mockito.mock(PSInfo.class);
setPsByStartAndTarget(daoObj, psObj, "psName");
-
+
Result<List<RoleDAO.Data>> rs1 = new Result<List<RoleDAO.Data>>(null,0,"test",new Object[0]);
Mockito.doReturn(rs1).when(psObj).read(trans, "RoleDAO READ", new Object[]{"test"});
-
+
daoObj.readName(trans, "test");
}
@Test
@@ -136,15 +136,15 @@ public class JU_RoleDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
PSInfo psObj = Mockito.mock(PSInfo.class);
setPsByStartAndTarget(daoObj, psObj, "psChildren");
-
+
Result<List<RoleDAO.Data>> rs1 = new Result<List<RoleDAO.Data>>(null,0,"test",new Object[0]);
Mockito.doReturn(rs1).when(psObj).read(trans, "RoleDAO READ", new Object[]{"test"});
-
+
daoObj.readChildren(trans, "test", "test");
-
+
daoObj.readChildren(trans, "test", "*");
daoObj.readChildren(trans, "test", "");
}
@@ -162,13 +162,13 @@ public class JU_RoleDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
PSInfo psObj = Mockito.mock(PSInfo.class);
setPsByStartAndTarget(daoObj, psObj, "psNS");
-
+
Result<List<RoleDAO.Data>> rs1 = new Result<List<RoleDAO.Data>>(null,0,"test",new Object[0]);
Mockito.doReturn(rs1).when(psObj).read(trans, "RoleDAO READ", new Object[]{"test"});
-
+
daoObj.readNS(trans, "test");
}
@Test
@@ -190,7 +190,7 @@ public class JU_RoleDAO {
Mockito.doReturn(tt).when(trans).start("Clear Reset Deque", Env.SUB);
Mockito.doReturn(tt).when(trans).start("New Cassandra Session", Env.SUB);
Mockito.doReturn(tt).when(trans).start("Preparing PSInfo CREATE on RoleDAO", Env.SUB);
-
+
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_PORT,"100");
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_PORT,"9042");
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_USER_NAME,"100");
@@ -202,10 +202,10 @@ public class JU_RoleDAO {
Mockito.doReturn(rs1).when(psObj).read(trans, "RoleDAOImpl READ", data);
Mockito.doReturn(rs1).when(psObj).exec(trans, "RoleDAOImpl DELETE", data);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
-
+
Result<Void> rs2 = new Result<Void>(null,0,"test",new Object[0]);
Mockito.doReturn(rs2).when(cacheInfoDAO).touch(Mockito.any(AuthzTrans.class),Mockito.anyString(), Mockito.anyVararg());
-
+
rs1 = new Result<List<Data>>(null,1,"test",new Object[0]);
Mockito.doReturn(rs1).when(cacheInfoDAO).touch(Mockito.any(), Mockito.anyString(), Mockito.anyInt());
Mockito.doReturn("test user").when(trans).user();
@@ -224,12 +224,12 @@ public class JU_RoleDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
PermDAO.Data perm = new PermDAO.Data();
RoleDAO.Data role = new RoleDAO.Data();
Result<Void> retVal = daoObj.addPerm(trans, role, perm);
assertTrue(retVal.status == 9);
-
+
Field owningField;
try {
owningField = AbsCassDAO.class.getDeclaredField("owningDAO");
@@ -248,7 +248,7 @@ public class JU_RoleDAO {
retVal = daoObj.addPerm(trans, role, perm);
assertTrue(retVal.status == 0);
}
-
+
@Test
public void testDelRole() {
PSInfo psObj = Mockito.mock(PSInfo.class);
@@ -268,7 +268,7 @@ public class JU_RoleDAO {
Mockito.doReturn(tt).when(trans).start("Clear Reset Deque", Env.SUB);
Mockito.doReturn(tt).when(trans).start("New Cassandra Session", Env.SUB);
Mockito.doReturn(tt).when(trans).start("Preparing PSInfo CREATE on RoleDAO", Env.SUB);
-
+
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_PORT,"100");
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_PORT,"9042");
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_USER_NAME,"100");
@@ -280,14 +280,14 @@ public class JU_RoleDAO {
Mockito.doReturn(rs1).when(psObj).read(trans, "RoleDAOImpl READ", data);
Mockito.doReturn(rs1).when(psObj).exec(trans, "RoleDAOImpl DELETE", data);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
-
+
Result<Void> rs2 = new Result<Void>(null,0,"test",new String[0]);
Mockito.doReturn(rs2).when(cacheInfoDAO).touch(Mockito.any(AuthzTrans.class),Mockito.anyString(), Mockito.anyVararg());
-
+
rs1 = new Result<List<Data>>(null,1,"test",new String[0]);
Mockito.doReturn(rs1).when(cacheInfoDAO).touch(Mockito.any(), Mockito.anyString(), Mockito.anyInt());
Mockito.doReturn("test user").when(trans).user();
-
+
PermDAO.Data perm = new PermDAO.Data();
Field cbField;
try {
@@ -307,7 +307,7 @@ public class JU_RoleDAO {
RoleDAO.Data role = new RoleDAO.Data();
Result<Void> retVal = daoObj.delPerm(trans, role, perm);
assertTrue(retVal.status == 9);
-
+
Field owningDaoField;
try {
owningDaoField = AbsCassDAO.class.getDeclaredField("owningDAO");
@@ -326,7 +326,7 @@ public class JU_RoleDAO {
retVal = daoObj.delPerm(trans,role, perm);
assertTrue(retVal.status == 0);
}
-
+
@Test
public void testAddDescription() {
PSInfo psObj = Mockito.mock(PSInfo.class);
@@ -346,7 +346,7 @@ public class JU_RoleDAO {
Mockito.doReturn(tt).when(trans).start("Clear Reset Deque", Env.SUB);
Mockito.doReturn(tt).when(trans).start("New Cassandra Session", Env.SUB);
Mockito.doReturn(tt).when(trans).start("Preparing PSInfo CREATE on RoleDAO", Env.SUB);
-
+
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_PORT,"100");
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_PORT,"9042");
Mockito.doReturn("100").when(trans).getProperty(CassAccess.CASSANDRA_CLUSTERS_USER_NAME,"100");
@@ -358,14 +358,14 @@ public class JU_RoleDAO {
Mockito.doReturn(rs1).when(psObj).read(trans, "RoleDAOImpl READ", data);
Mockito.doReturn(rs1).when(psObj).exec(trans, "RoleDAOImpl DELETE", data);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
-
+
Result<Void> rs2 = new Result<Void>(null,1,"test",new String[0]);
Mockito.doReturn(rs2).when(cacheInfoDAO).touch(Mockito.any(AuthzTrans.class),Mockito.anyString(), Mockito.anyVararg());
-
+
rs1 = new Result<List<Data>>(null,1,"test",new String[0]);
Mockito.doReturn(rs1).when(cacheInfoDAO).touch(Mockito.any(), Mockito.anyString(), Mockito.anyInt());
Mockito.doReturn("test user").when(trans).user();
-
+
RoleDAO.Data perm = new RoleDAO.Data();
Field cbField;
try {
@@ -382,10 +382,10 @@ public class JU_RoleDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
Result<Void> retVal = daoObj.addDescription(trans, "test", "test", "test");
assertTrue(retVal.status == 9);
-
+
Field owningDaoField;
try {
owningDaoField = AbsCassDAO.class.getDeclaredField("owningDAO");
@@ -404,18 +404,18 @@ public class JU_RoleDAO {
retVal = daoObj.addDescription(trans, "test", "test", "test");
assertTrue(retVal.status == 0);
}
-
+
public void setPsByStartAndTarget(RoleDAO RoleDAOObj, PSInfo psInfoObj, String fieldName) {
Field RoleDAOField;
try {
RoleDAOField = RoleDAO.class.getDeclaredField(fieldName);
-
+
RoleDAOField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(RoleDAOField, RoleDAOField.getModifiers() & ~Modifier.FINAL);
-
+
RoleDAOField.set(RoleDAOObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -428,7 +428,7 @@ public class JU_RoleDAO {
e.printStackTrace();
}
}
-
+
@Test
public void testWasModified() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -441,15 +441,15 @@ public class JU_RoleDAO {
Mockito.doNothing().when(tt).done();
RoleDAO.Data data = new RoleDAO.Data();
PSInfo createPS = Mockito.mock(PSInfo.class);
-
+
HistoryDAO historyDAO = Mockito.mock(HistoryDAO.class);
Result<ResultSet> rs1 = new Result<ResultSet>(null,0,"test",new String[0]);
Result<Void> rs2 = new Result<Void>(null,0,"test",new String[0]);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
-
+
CacheInfoDAO cacheInfoDAO = Mockito.mock(CacheInfoDAO.class);
Mockito.doReturn(rs2).when(cacheInfoDAO).touch(Mockito.any(AuthzTrans.class),Mockito.anyString(), Mockito.anyVararg());
-
+
RoleDAOImpl daoObj = null;
try {
daoObj = new RoleDAOImpl(trans, historyDAO, cacheInfoDAO, createPS );
@@ -458,24 +458,24 @@ public class JU_RoleDAO {
e.printStackTrace();
}
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test"});
-
+
daoObj.wasModified(trans, CRUD.create, data, new String[] {});
daoObj.wasModified(trans, CRUD.create, data, new String[] {null});
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test",null});
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test","test"});
-
+
rs1 = new Result<ResultSet>(null,1,"test",new String[0]);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
daoObj.wasModified(trans, CRUD.delete, data, new String[] {"test","test"});
}
-
+
@Test
public void testSecondConstructor() {
HistoryDAO historyDAO = Mockito.mock(HistoryDAO.class);
CacheInfoDAO cacheInfoDAO = Mockito.mock(CacheInfoDAO.class);
RoleDAO daoObj = new RoleDAO(trans, historyDAO, cacheInfoDAO);
-
+
}
@Test
@@ -488,15 +488,15 @@ public class JU_RoleDAO {
break;
}
}
-
+
Constructor<?> constructor = innerClass.getDeclaredConstructors()[0];
constructor.setAccessible(true);
-
+
try {
-
+
Object obj = constructor.newInstance(1);
Method innnerClassMtd;
-
+
RoleDAO.Data data = new RoleDAO.Data();
Row row = Mockito.mock(Row.class);
ByteBuffer bbObj = ByteBuffer.allocateDirect(10);
@@ -505,16 +505,16 @@ public class JU_RoleDAO {
bbObj.put(1, new Byte("1"));
bbObj.put(2, new Byte("2"));
Mockito.doReturn(bbObj).when(row).getBytesUnsafe(1);
-
+
innnerClassMtd = innerClass.getMethod("load", new Class[] {RoleDAO.Data.class, Row.class});
innnerClassMtd.invoke(obj, new Object[] {data, row});
-
+
innnerClassMtd = innerClass.getDeclaredMethod("key", new Class[] {RoleDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test","test","test"} });
-//
+//
innnerClassMtd = innerClass.getDeclaredMethod("body", new Class[] {RoleDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test","test","test","test","test","test","test","test","test"} });
-
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
innnerClassMtd = innerClass.getDeclaredMethod("marshal", new Class[] {RoleDAO.Data.class, DataOutputStream.class });
@@ -524,7 +524,7 @@ public class JU_RoleDAO {
DataInputStream dis = new DataInputStream(bais);
innnerClassMtd = innerClass.getDeclaredMethod("unmarshal", new Class[] {RoleDAO.Data.class, DataInputStream.class });
innnerClassMtd.invoke(obj, new Object[] {data, dis });
-
+
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -543,20 +543,20 @@ public class JU_RoleDAO {
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- }
+ }
}
-
+
@Test
public void testData() {
RoleDAO.Data data = new RoleDAO.Data();
NsSplit nss = new NsSplit("test", "test");
data = new RoleDAO.Data();
-
+
data.toString();
-
-
+
+
Question q = Mockito.mock( Question.class);
-
+
Result<NsSplit> rs = new Result<NsSplit>(nss,0,"test",new Object[0]);
Mockito.doReturn(rs).when(q).deriveNsSplit(trans, "test");
Result<Data> retVal= RoleDAO.Data.decode(trans, q, "test|||");
@@ -566,7 +566,7 @@ public class JU_RoleDAO {
retVal= RoleDAO.Data.decode(trans, q, "test");
retVal1= RoleDAO.Data.decodeToArray(trans, q, "test");
assertTrue(retVal.status==0);
-
+
rs = new Result<NsSplit>(nss,1,"test",new Object[0]);
Mockito.doReturn(rs).when(q).deriveNsSplit(trans, "test");
retVal= RoleDAO.Data.decode(trans, q, "test");
@@ -576,7 +576,7 @@ public class JU_RoleDAO {
retVal= RoleDAO.Data.decode(trans, q, "test");
retVal1= RoleDAO.Data.decodeToArray(trans, q, "test");
assertTrue(retVal.status==1);
-
+
NsDAO.Data ns = new NsDAO.Data();
ns.name="test";
RoleDAO.Data.create(ns, "test");
@@ -585,9 +585,9 @@ public class JU_RoleDAO {
urdd.ns="test";
RoleDAO.Data dd=RoleDAO.Data.decode(urdd);
assertTrue("test".equals(dd.ns));
-
+
assertTrue(data.encode().contains("null"));
-
+
data.perms = null;
data.perms(true);
@@ -598,7 +598,7 @@ public class JU_RoleDAO {
data.perms = new TreeSet<>();
data.perms(true);
}
-
+
}
class RoleDAOImpl extends RoleDAO{
@@ -606,25 +606,25 @@ class RoleDAOImpl extends RoleDAO{
super(trans, historyDAO, cacheDao);
setPs(this, readPS, "createPS");
}
-
+
public RoleDAOImpl(AuthzTrans trans, HistoryDAO historyDAO,CacheInfoDAO cacheDao, PSInfo readPS, Session session ) throws APIException, IOException {
super(trans, historyDAO, cacheDao);
setPs(this, readPS, "createPS");
setSession(this, session);
}
-
+
public void setPs(RoleDAOImpl RoleDAOObj, PSInfo psInfoObj, String methodName) {
Field RoleDAOField;
try {
RoleDAOField = CassDAOImpl.class.getDeclaredField(methodName);
-
+
RoleDAOField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(RoleDAOField, RoleDAOField.getModifiers() & ~Modifier.FINAL);
-
+
RoleDAOField.set(RoleDAOObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -637,18 +637,18 @@ class RoleDAOImpl extends RoleDAO{
e.printStackTrace();
}
}
-
+
public void setSession(RoleDAOImpl approvalDaoObj, Session session) {
Field nsDaoField;
try {
nsDaoField = AbsCassDAO.class.getDeclaredField("session");
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
nsDaoField.set(approvalDaoObj, session);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_UserRoleDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_UserRoleDAO.java
index 43496fd5..22824fd5 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_UserRoleDAO.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_UserRoleDAO.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -66,7 +66,7 @@ public class JU_UserRoleDAO {
Cluster cluster;
@Mock
Session session;
-
+
@Before
public void setUp() throws APIException, IOException {
initMocks(this);
@@ -109,13 +109,13 @@ public class JU_UserRoleDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
PSInfo psObj = Mockito.mock(PSInfo.class);
setPsByStartAndTarget(daoObj, psObj, "psByUser");
-
+
Result<List<UserRoleDAO.Data>> rs1 = new Result<List<UserRoleDAO.Data>>(null,0,"test",new Object[0]);
Mockito.doReturn(rs1).when(psObj).read(trans, "UserRoleDAO READ", new Object[]{"test"});
-
+
daoObj.readByUser(trans, "test");
}
@Test
@@ -132,13 +132,13 @@ public class JU_UserRoleDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
PSInfo psObj = Mockito.mock(PSInfo.class);
setPsByStartAndTarget(daoObj, psObj, "psByRole");
-
+
Result<List<UserRoleDAO.Data>> rs1 = new Result<List<UserRoleDAO.Data>>(null,0,"test",new Object[0]);
Mockito.doReturn(rs1).when(psObj).read(trans, "UserRoleDAO READ", new Object[]{"test"});
-
+
daoObj.readByRole(trans, "test");
}
@Test
@@ -155,28 +155,28 @@ public class JU_UserRoleDAO {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
PSInfo psObj = Mockito.mock(PSInfo.class);
setPsByStartAndTarget(daoObj, psObj, "psUserInRole");
-
+
Result<List<UserRoleDAO.Data>> rs1 = new Result<List<UserRoleDAO.Data>>(null,0,"test",new Object[0]);
Mockito.doReturn(rs1).when(psObj).read(trans, "UserRoleDAO READ", new Object[]{"test"});
-
+
daoObj.readByUserRole(trans, "test","test");
}
-
-
+
+
public void setPsByStartAndTarget(UserRoleDAO UserRoleDAOObj, PSInfo psInfoObj, String fieldName) {
Field UserRoleDAOField;
try {
UserRoleDAOField = UserRoleDAO.class.getDeclaredField(fieldName);
-
+
UserRoleDAOField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(UserRoleDAOField, UserRoleDAOField.getModifiers() & ~Modifier.FINAL);
-
+
UserRoleDAOField.set(UserRoleDAOObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -189,7 +189,7 @@ public class JU_UserRoleDAO {
e.printStackTrace();
}
}
-
+
@Test
public void testWasMOdified() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
@@ -202,15 +202,15 @@ public class JU_UserRoleDAO {
Mockito.doNothing().when(tt).done();
UserRoleDAO.Data data = new UserRoleDAO.Data();
PSInfo createPS = Mockito.mock(PSInfo.class);
-
+
HistoryDAO historyDAO = Mockito.mock(HistoryDAO.class);
Result<ResultSet> rs1 = new Result<ResultSet>(null,0,"test",new Object[0]);
Result<Void> rs2 = new Result<Void>(null,0,"test",new Object[0]);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
-
+
CacheInfoDAO cacheInfoDAO = Mockito.mock(CacheInfoDAO.class);
Mockito.doReturn(rs2).when(cacheInfoDAO).touch(Mockito.any(AuthzTrans.class),Mockito.anyString(), Mockito.anyVararg());
-
+
UserRoleDAOImpl daoObj = null;
try {
daoObj = new UserRoleDAOImpl(trans, historyDAO, cacheInfoDAO, createPS );
@@ -219,7 +219,7 @@ public class JU_UserRoleDAO {
e.printStackTrace();
}
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test"});
-
+
daoObj.wasModified(trans, CRUD.update, data, new String[] {});
daoObj.wasModified(trans, CRUD.create, data, new String[] {null});
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test",null});
@@ -227,24 +227,24 @@ public class JU_UserRoleDAO {
daoObj.wasModified(trans, CRUD.delete, data, new String[] {"test","test"});
daoObj.wasModified(trans, CRUD.delete, data, new String[] {});
-
+
rs2 = new Result<Void>(null,1,"test",new Object[0]);
Mockito.doReturn(rs2).when(cacheInfoDAO).touch(Mockito.any(AuthzTrans.class),Mockito.anyString(), Mockito.anyVararg());
daoObj.wasModified(trans, CRUD.read, data, new String[] {"test","test"});
daoObj.wasModified(trans, CRUD.read, data, new String[] {});
-
+
rs1 = new Result<ResultSet>(null,1,"test",new String[0]);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
daoObj.wasModified(trans, CRUD.delete, data, new String[] {"test","test"});
}
-
+
@Test
public void testSecondConstructor() {
HistoryDAO historyDAO = Mockito.mock(HistoryDAO.class);
CacheInfoDAO cacheInfoDAO = Mockito.mock(CacheInfoDAO.class);
UserRoleDAO daoObj = new UserRoleDAO(trans, historyDAO, cacheInfoDAO);
-
+
}
@Test
@@ -257,15 +257,15 @@ public class JU_UserRoleDAO {
break;
}
}
-
+
Constructor<?> constructor = innerClass.getDeclaredConstructors()[0];
constructor.setAccessible(true);
-
+
try {
-
+
Object obj = constructor.newInstance(1);
Method innnerClassMtd;
-
+
UserRoleDAO.Data data = new UserRoleDAO.Data();
Row row = Mockito.mock(Row.class);
ByteBuffer bbObj = ByteBuffer.allocateDirect(10);
@@ -274,16 +274,16 @@ public class JU_UserRoleDAO {
bbObj.put(1, new Byte("1"));
bbObj.put(2, new Byte("2"));
Mockito.doReturn(bbObj).when(row).getBytesUnsafe(1);
-
+
innnerClassMtd = innerClass.getMethod("load", new Class[] {UserRoleDAO.Data.class, Row.class});
innnerClassMtd.invoke(obj, new Object[] {data, row});
-
+
innnerClassMtd = innerClass.getDeclaredMethod("key", new Class[] {UserRoleDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test","test","test"} });
-//
+//
innnerClassMtd = innerClass.getDeclaredMethod("body", new Class[] {UserRoleDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test","test","test","test","test","test","test","test","test"} });
-
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
innnerClassMtd = innerClass.getDeclaredMethod("marshal", new Class[] {UserRoleDAO.Data.class, DataOutputStream.class });
@@ -293,7 +293,7 @@ public class JU_UserRoleDAO {
DataInputStream dis = new DataInputStream(bais);
innnerClassMtd = innerClass.getDeclaredMethod("unmarshal", new Class[] {UserRoleDAO.Data.class, DataInputStream.class });
innnerClassMtd.invoke(obj, new Object[] {data, dis });
-
+
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -312,36 +312,36 @@ public class JU_UserRoleDAO {
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- }
+ }
}
-
+
@Test
public void testData() {
UserRoleDAO.Data data = new UserRoleDAO.Data();
NsSplit nss = new NsSplit("test", "test");
data = new UserRoleDAO.Data();
-
+
data.toString();
data.role("test", "test");
assertTrue("test".equals(data.ns));
-
+
RoleDAO.Data rdd = new RoleDAO.Data();
rdd.ns="test";
data.role(rdd);
assertTrue("test".equals(data.ns));
-
+
Question q = Mockito.mock( Question.class);
Result<NsSplit> rs = new Result<NsSplit>(nss,0,"test",new Object[0]);
Mockito.doReturn(rs).when(q).deriveNsSplit(trans, "test");
-
+
data.role(trans, q, "test");
-
+
rs = new Result<NsSplit>(nss,1,"test",new Object[0]);
Mockito.doReturn(rs).when(q).deriveNsSplit(trans, "test");
-
+
data.role(trans, q, "test");
}
-
+
}
class UserRoleDAOImpl extends UserRoleDAO{
@@ -349,25 +349,25 @@ class UserRoleDAOImpl extends UserRoleDAO{
super(trans, historyDAO, cacheDao);
setPs(this, readPS, "createPS");
}
-
+
public UserRoleDAOImpl(AuthzTrans trans, HistoryDAO historyDAO,CacheInfoDAO cacheDao, PSInfo readPS, Session session ) throws APIException, IOException {
super(trans, historyDAO, cacheDao);
setPs(this, readPS, "createPS");
setSession(this, session);
}
-
+
public void setPs(UserRoleDAOImpl UserRoleDAOObj, PSInfo psInfoObj, String methodName) {
Field UserRoleDAOField;
try {
UserRoleDAOField = CassDAOImpl.class.getDeclaredField(methodName);
-
+
UserRoleDAOField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(UserRoleDAOField, UserRoleDAOField.getModifiers() & ~Modifier.FINAL);
-
+
UserRoleDAOField.set(UserRoleDAOObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
@@ -380,18 +380,18 @@ class UserRoleDAOImpl extends UserRoleDAO{
e.printStackTrace();
}
}
-
+
public void setSession(UserRoleDAOImpl approvalDaoObj, Session session) {
Field nsDaoField;
try {
nsDaoField = AbsCassDAO.class.getDeclaredField("session");
-
+
nsDaoField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL);
-
+
nsDaoField.set(approvalDaoObj, session);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/hl/JU_CassExecutor.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/hl/JU_CassExecutor.java
index 6d029933..8305944f 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/hl/JU_CassExecutor.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/hl/JU_CassExecutor.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -43,24 +43,24 @@ import org.onap.aaf.cadi.Access;
import org.onap.aaf.cadi.CadiException;
-@RunWith(MockitoJUnitRunner.class)
+@RunWith(MockitoJUnitRunner.class)
public class JU_CassExecutor {
-
-
+
+
private static final Object NO_PARAM = new Object[0];
@Mock
AuthzTransImpl trans;
-
+
@Mock
Question q;
-
+
@Mock
Access access;
-
+
Function f;
-
+
@Before
public void setUp() throws Exception {
initMocks(this);
@@ -74,36 +74,36 @@ public class JU_CassExecutor {
}
f =new Function(trans, q);
}
-
+
@Test
public void testHasPermission() {
-
+
CassExecutor cassExecutorObj =new CassExecutor(trans, f);
Mockito.doReturn(false).when(q).isGranted(trans, "","","","","");
boolean retVal = cassExecutorObj.hasPermission("", "", "", "", "");
// System.out.println(retVal);
assertFalse(retVal);
- }
-
+ }
+
@Test
public void testInRole() {
-
+
CassExecutor cassExecutorObj =new CassExecutor(trans, f);
Result<NsSplit> retVal1 = new Result<NsSplit>(null,1,"",NO_PARAM);
Mockito.doReturn(retVal1).when(q).deriveNsSplit(trans, "test");
-
+
boolean retVal = cassExecutorObj.inRole("test");
// System.out.println(retVal);
assertFalse(retVal);
}
-
+
@Test
public void testNamespace() {
f =new Function(trans, q);
CassExecutor cassExecutorObj =new CassExecutor(trans, f);
Result<Data> retVal1 = new Result<Data>(null,1,"",NO_PARAM);
Mockito.doReturn(retVal1).when(q).validNSOfDomain(trans, null);
-
+
String retVal="";
try {
retVal = cassExecutorObj.namespace();
@@ -114,7 +114,7 @@ public class JU_CassExecutor {
System.out.println(retVal);
// assertFalse(retVal);
}
-
+
@Test
public void testId() {
Mockito.doReturn("").when(trans).user();
@@ -122,7 +122,7 @@ public class JU_CassExecutor {
String retVal = cassExecutorObj.id();
assertEquals("", retVal);
}
-
+
@Test
public void testNamespaceSuccess() {
Mockito.doAnswer(new Answer<Object>() {
@@ -139,8 +139,8 @@ public class JU_CassExecutor {
CassExecutor cassExecutorObj =new CassExecutor(trans, f);
Result<Data> retVal1 = new Result<Data>(null,0,"",NO_PARAM);
Mockito.doReturn(retVal1).when(q).validNSOfDomain(trans, null);
-
-
+
+
// String retVal="";
try {
/*retVal =*/ cassExecutorObj.namespace();
@@ -152,5 +152,5 @@ public class JU_CassExecutor {
// System.out.println(retVal);
// assertFalse(retVal);
}
-
+
} \ No newline at end of file
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/hl/JU_Function.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/hl/JU_Function.java
index bfa5838c..cb52cf44 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/hl/JU_Function.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/hl/JU_Function.java
@@ -7,9 +7,9 @@
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
- * *
+ * *
* * http://www.apache.org/licenses/LICENSE-2.0
- * *
+ * *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -81,21 +81,21 @@ import org.onap.aaf.misc.env.LogTarget;
public class JU_Function {
private static final Object NO_PARAM = new Object[0];
-
+
@Mock
AuthzTrans trans;
@Mock
PropAccess access;
-
+
@Mock
Question ques;
-
- @Mock
+
+ @Mock
Organization org;
-
+
@Mock
CachedNSDAO nsDAO;
-
+
@Mock
CachedRoleDAO roleDAO;
@@ -131,7 +131,7 @@ public class JU_Function {
Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).debug();
Mockito.doReturn(Mockito.mock(Properties.class)).when(access).getProperties();
Mockito.doReturn("test.test").when(access).getProperty(Config.AAF_ROOT_NS,"org.osaaf.aaf");
-
+
try {
Define.set(access);
} catch (CadiException e) {
@@ -154,14 +154,14 @@ public class JU_Function {
Mockito.doReturn(retVal1).when(ques).deriveNs(trans, "test");
Result<Void> retVal = new Result<Void>(null,1,"test",NO_PARAM);
- Mockito.doReturn(retVal).when(nsDAO).read(Mockito.any(), Mockito.anyString());
+ Mockito.doReturn(retVal).when(nsDAO).read(Mockito.any(), Mockito.anyString());
//setQuestion(ques, cachedNS);
-
+
Function funcObj = new Function(trans, ques);
Result<Void> result = funcObj.createNS(trans, namespace, true);
assertTrue(3 == result.status);
}
-
+
@Test
public void testCreateNsReadSuccess() {
Namespace namespace = Mockito.mock(Namespace.class);
@@ -172,50 +172,50 @@ public class JU_Function {
List<String> admin = new ArrayList<String>();
admin.add("test");
namespace.admin= admin;
-
+
Organization org = Mockito.mock(Organization.class);
Mockito.doReturn(org).when(trans).org();
-
+
NsDAO.Data data = new NsDAO.Data();
data.name="test";
Result<NsDAO.Data> retVal1 = new Result<NsDAO.Data>(data,0,"test",NO_PARAM);
Mockito.doReturn(retVal1).when(ques).deriveNs(trans, "test");
Result<Void> retVal = new Result<Void>(null,1,"test",NO_PARAM);
- Mockito.doReturn(retVal).when(nsDAO).read(Mockito.any(), Mockito.anyString());
-
+ Mockito.doReturn(retVal).when(nsDAO).read(Mockito.any(), Mockito.anyString());
+
Function funcObj = new Function(trans, ques);
Result<Void> result = funcObj.createNS(trans, namespace, true);
assertTrue(3 == result.status);
}
-
+
@Test
public void testCreateNsFromApprovaFalse() {
Namespace namespace = Mockito.mock(Namespace.class);
namespace.name = "test.test";
List<String> owner = new ArrayList<String>();
namespace.owner = owner;
-
+
Organization org = Mockito.mock(Organization.class);
Mockito.doReturn(org).when(trans).org();
-
+
NsDAO.Data data = new NsDAO.Data();
data.name="test";
Result<NsDAO.Data> retVal1 = new Result<NsDAO.Data>(data,0,"test",NO_PARAM);
Mockito.doReturn(retVal1).when(ques).deriveNs(trans, "test");
Result<NsDAO.Data> retVal2 = new Result<NsDAO.Data>(data,1,"test",NO_PARAM);
Mockito.doReturn(retVal2).when(ques).mayUser(trans, null,retVal1.value, Access.write);
-
+
Function funcObj = new Function(trans, ques);
Result<Void> result = funcObj.createNS(trans, namespace, false);
assertTrue(1 == result.status);
-
+
Mockito.doReturn(retVal2).when(ques).deriveNs(trans, "test");
funcObj = new Function(trans, ques);
result = funcObj.createNS(trans, namespace, false);
assertTrue(1 == result.status);
}
-
+
@Test
public void testCreateNsownerLoop() {
Namespace namespace = Mockito.mock(Namespace.class);
@@ -223,16 +223,16 @@ public class JU_Function {
List<String> owner = new ArrayList<String>();
owner.add("test");
namespace.owner = owner;
-
+
Organization org = Mockito.mock(Organization.class);
Mockito.doReturn(org).when(trans).org();
Mockito.doReturn(org).when(trans).org();
-
+
Function funcObj = new Function(trans, ques);
Result<Void> result = funcObj.createNS(trans, namespace, true);
assertTrue(result.status == Status.ERR_Policy);
assertTrue(result.details.contains("is not a valid user at"));
-
+
Identity iden=Mockito.mock(Identity.class);
try {
Mockito.doReturn(iden).when(org).getIdentity(trans, "test");
@@ -249,7 +249,7 @@ public class JU_Function {
result = funcObj.createNS(trans, namespace, true);
assertTrue(result.status == Status.ERR_Policy);
assertTrue(result.details.contains("cannot be the owner of the namespace "));
-
+
Mockito.doReturn(true).when(org).isTestEnv();
try {
Mockito.doReturn("test").when(org).validate(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any());
@@ -261,7 +261,7 @@ public class JU_Function {
e.printStackTrace();
}
}
-
+
@Test
public void testCreateNsownerLoopException() {
Namespace namespace = Mockito.mock(Namespace.class);
@@ -269,12 +269,12 @@ public class JU_Function {
List<String> owner = new ArrayList<String>();
owner.add("test");
namespace.owner = owner;
-
+
Organization org = Mockito.mock(Organization.class);
Mockito.doReturn(org).when(trans).org();
-
+
Function funcObj = new Function(trans, ques);
-
+
Identity iden=Mockito.mock(Identity.class);
try {
Mockito.doThrow(new OrganizationException()).when(org).getIdentity(trans, "test");
@@ -283,26 +283,26 @@ public class JU_Function {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
NsDAO.Data data = new NsDAO.Data();
data.name="test";
Result<NsDAO.Data> retVal1 = new Result<NsDAO.Data>(data,1,"test",NO_PARAM);
Mockito.doReturn(retVal1).when(ques).deriveNs(trans, "test");
-
+
Result<Void> result = funcObj.createNS(trans, namespace, true);
assertTrue(result.status == Status.ERR_Security);
assertTrue(result.details.contains("may not create Root Namespaces"));
-
+
Mockito.doReturn(true).when(ques).isGranted(Mockito.any(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString());
retVal1 = new Result<NsDAO.Data>(data,0,"test",NO_PARAM);
Mockito.doReturn(retVal1).when(ques).deriveNs(trans, null);
-
+
Result<Void> retVal = new Result<Void>(null,1,"test",NO_PARAM);
- Mockito.doReturn(retVal).when(nsDAO).read(Mockito.any(), Mockito.anyString());
-
+ Mockito.doReturn(retVal).when(nsDAO).read(Mockito.any(), Mockito.anyString());
+
result = funcObj.createNS(trans, namespace, true);
assertTrue(24 == result.status);
-
+
}
@Test
@@ -313,15 +313,15 @@ public class JU_Function {
owner.add("test");
namespace.owner = owner;
namespace.admin = owner;
-
+
Organization org = Mockito.mock(Organization.class);
Mockito.doReturn(org).when(trans).org();
-
+
NsDAO.Data data = new NsDAO.Data();
data.name="test";
Result<NsDAO.Data> retVal1 = new Result<NsDAO.Data>(data,0,"test",NO_PARAM);
Mockito.doReturn(retVal1).when(ques).deriveNs(trans, "test");
-
+
Result<Void> retVal = new Result<Void>(null,1,"test",NO_PARAM);
Mockito.doReturn(retVal).when(nsDAO).read(Mockito.any(), Mockito.anyString());
Mockito.doReturn(retVal).when(nsDAO).create(Mockito.any(), Mockito.any());
@@ -338,8 +338,8 @@ public class JU_Function {
}
dataObj.add(indData);
Result<List<CredDAO.Data>> retVal2 = new Result<List<CredDAO.Data>>(dataObj,0,"test",NO_PARAM);
- Mockito.doReturn(retVal2).when(credDAO).readID(Mockito.any(), Mockito.anyString());
-
+ Mockito.doReturn(retVal2).when(credDAO).readID(Mockito.any(), Mockito.anyString());
+
Identity iden=Mockito.mock(Identity.class);
try {
Mockito.doReturn(iden).when(org).getIdentity(trans, "test");
@@ -349,16 +349,16 @@ public class JU_Function {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
Mockito.doReturn(Result.err(Result.ERR_NotFound, "Not Found")).when(roleDAO).read(trans, "test","test");
Mockito.doReturn(Result.err(Result.ERR_NotFound, "Not Found")).when(permDAO).readByType(trans, "test","test");
Function funcObj = new Function(trans, ques);
Result<Void> result = funcObj.createNS(trans, namespace, true);
assertTrue(result.status == 1);
-
+
}
-
+
@Test
public void testCreateNsAdminLoopCreateSucReadChildrenFailure() {
Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).error();
@@ -377,15 +377,15 @@ public class JU_Function {
owner.add("test");
namespace.owner = owner;
namespace.admin = owner;
-
+
Organization org = Mockito.mock(Organization.class);
Mockito.doReturn(org).when(trans).org();
-
+
NsDAO.Data data = new NsDAO.Data();
data.name="test";
Result<NsDAO.Data> retVal1 = new Result<NsDAO.Data>(data,0,"test",NO_PARAM);
Mockito.doReturn(retVal1).when(ques).deriveNs(trans, "test");
-
+
Result<Void> retVal = new Result<Void>(null,0,"test",NO_PARAM);
Mockito.doReturn(retVal).when(nsDAO).read(Mockito.any(), Mockito.anyString());
Mockito.doReturn(retVal).when(nsDAO).create(Mockito.any(), Mockito.any());
@@ -409,34 +409,34 @@ public class JU_Function {
permsSet.add("test|test");
indData1.perms = permsSet;
dataObj1.add(indData1);
-
+
List<UserRoleDAO.Data> dataObj4 = new ArrayList<>();
UserRoleDAO.Data indData4 = new UserRoleDAO.Data();
indData4.ns = "test";
indData4.rname = "test";
dataObj4.add(indData4);
-
+
List<PermDAO.Data> dataObj5 = new ArrayList<>();
PermDAO.Data indData5 = new PermDAO.Data();
indData5.ns = "test";
indData5.type = "test";
dataObj5.add(indData5);
-
+
Result<List<CredDAO.Data>> retVal2 = new Result<List<CredDAO.Data>>(dataObj,0,"test",NO_PARAM);
Result<List<CredDAO.Data>> retVal6 = new Result<List<CredDAO.Data>>(dataObj,1,"test",NO_PARAM);
Result<List<RoleDAO.Data>> retVal3 = new Result<List<RoleDAO.Data>>(dataObj1,0,"test",NO_PARAM);
Result<List<UserRoleDAO.Data>> retVal4 = new Result<List<UserRoleDAO.Data>>(dataObj4,0,"test",NO_PARAM);
Result<List<PermDAO.Data>> retVal5 = new Result<List<PermDAO.Data>>(dataObj5,0,"test",NO_PARAM);
- Mockito.doReturn(retVal2).when(credDAO).readID(Mockito.any(), Mockito.anyString());
- Mockito.doReturn(retVal4).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
- Mockito.doReturn(retVal2).when(userRoleDAO).create(Mockito.any(), Mockito.any());
- Mockito.doReturn(retVal6).when(roleDAO).create(Mockito.any(), Mockito.any());
- Mockito.doReturn(retVal6).when(roleDAO).delete(Mockito.any(), Mockito.any(), Mockito.anyBoolean());
- Mockito.doReturn(retVal2).when(permDAO).create(Mockito.any(), Mockito.any());
- Mockito.doReturn(retVal5).when(permDAO).readChildren(trans, "test", "test");
- Mockito.doReturn(retVal5).when(permDAO).delete(Mockito.any(), Mockito.any(), Mockito.anyBoolean());
- Mockito.doReturn(retVal3).when(roleDAO).readChildren(trans, "test", "test");
-
+ Mockito.doReturn(retVal2).when(credDAO).readID(Mockito.any(), Mockito.anyString());
+ Mockito.doReturn(retVal4).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
+ Mockito.doReturn(retVal2).when(userRoleDAO).create(Mockito.any(), Mockito.any());
+ Mockito.doReturn(retVal6).when(roleDAO).create(Mockito.any(), Mockito.any());
+ Mockito.doReturn(retVal6).when(roleDAO).delete(Mockito.any(), Mockito.any(), Mockito.anyBoolean());
+ Mockito.doReturn(retVal2).when(permDAO).create(Mockito.any(), Mockito.any());
+ Mockito.doReturn(retVal5).when(permDAO).readChildren(trans, "test", "test");
+ Mockito.doReturn(retVal5).when(permDAO).delete(Mockito.any(), Mockito.any(), Mockito.anyBoolean());
+ Mockito.doReturn(retVal3).when(roleDAO).readChildren(trans, "test", "test");
+
Identity iden=Mockito.mock(Identity.class);
try {
Mockito.doReturn(iden).when(org).getIdentity(trans, "test");
@@ -447,16 +447,16 @@ public class JU_Function {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
Function funcObj = new Function(trans, ques);
Mockito.doReturn(Result.err(Result.ERR_NotFound, "Not Found")).when(roleDAO).read(trans, "test","test");
Mockito.doReturn(Result.err(Result.ERR_NotFound, "Not Found")).when(permDAO).readByType(trans, "test","test");
Result<Void> result = funcObj.createNS(trans, namespace, true);
assertTrue(result.status == Status.ERR_ActionNotCompleted);
-
+
}
-
+
@Test
public void testCreateNsAdminLoopCreateSuc() {
Namespace namespace = Mockito.mock(Namespace.class);
@@ -465,15 +465,15 @@ public class JU_Function {
owner.add("test");
namespace.owner = owner;
namespace.admin = owner;
-
+
Organization org = Mockito.mock(Organization.class);
Mockito.doReturn(org).when(trans).org();
-
+
NsDAO.Data data = new NsDAO.Data();
data.name="test";
Result<NsDAO.Data> retVal1 = new Result<NsDAO.Data>(data,0,"test",NO_PARAM);
Mockito.doReturn(retVal1).when(ques).deriveNs(trans, "test");
-
+
Result<Void> retVal = new Result<Void>(null,0,"test",NO_PARAM);
Mockito.doReturn(retVal).when(nsDAO).read(Mockito.any(), Mockito.anyString());
Mockito.doReturn(retVal).when(nsDAO).create(Mockito.any(), Mockito.any());
@@ -497,13 +497,13 @@ public class JU_Function {
permsSet.add("test|test|test|test");
indData1.perms = permsSet;
dataObj1.add(indData1);
-
+
List<UserRoleDAO.Data> dataObj4 = new ArrayList<>();
UserRoleDAO.Data indData4 = new UserRoleDAO.Data();
indData4.ns = "test";
indData4.rname = "test";
dataObj4.add(indData4);
-
+
List<PermDAO.Data> dataObj5 = new ArrayList<>();
PermDAO.Data indData5 = new PermDAO.Data();
indData5.ns = "test";
@@ -512,21 +512,21 @@ public class JU_Function {
rolesSet.add("test|test|test|test");
indData5.roles = rolesSet;
dataObj5.add(indData5);
-
+
Result<List<CredDAO.Data>> retVal2 = new Result<List<CredDAO.Data>>(dataObj,0,"test",NO_PARAM);
Result<List<RoleDAO.Data>> retVal3 = new Result<List<RoleDAO.Data>>(dataObj1,0,"test",NO_PARAM);
Result<List<UserRoleDAO.Data>> retVal4 = new Result<List<UserRoleDAO.Data>>(dataObj4,0,"test",NO_PARAM);
Result<List<PermDAO.Data>> retVal5 = new Result<List<PermDAO.Data>>(dataObj5,0,"test",NO_PARAM);
- Mockito.doReturn(retVal2).when(credDAO).readID(Mockito.any(), Mockito.anyString());
- Mockito.doReturn(retVal4).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
- Mockito.doReturn(retVal2).when(userRoleDAO).create(Mockito.any(), Mockito.any());
- Mockito.doReturn(retVal2).when(roleDAO).create(Mockito.any(), Mockito.any());
- Mockito.doReturn(retVal2).when(roleDAO).delete(Mockito.any(), Mockito.any(), Mockito.anyBoolean());
- Mockito.doReturn(retVal2).when(permDAO).create(Mockito.any(), Mockito.any());
- Mockito.doReturn(retVal5).when(permDAO).readChildren(trans, "test", "test");
- Mockito.doReturn(retVal5).when(permDAO).delete(Mockito.any(), Mockito.any(), Mockito.anyBoolean());
- Mockito.doReturn(retVal3).when(roleDAO).readChildren(trans, "test", "test");
-
+ Mockito.doReturn(retVal2).when(credDAO).readID(Mockito.any(), Mockito.anyString());
+ Mockito.doReturn(retVal4).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
+ Mockito.doReturn(retVal2).when(userRoleDAO).create(Mockito.any(), Mockito.any());
+ Mockito.doReturn(retVal2).when(roleDAO).create(Mockito.any(), Mockito.any());
+ Mockito.doReturn(retVal2).when(roleDAO).delete(Mockito.any(), Mockito.any(), Mockito.anyBoolean());
+ Mockito.doReturn(retVal2).when(permDAO).create(Mockito.any(), Mockito.any());
+ Mockito.doReturn(retVal5).when(permDAO).readChildren(trans, "test", "test");
+ Mockito.doReturn(retVal5).when(permDAO).delete(Mockito.any(), Mockito.any(), Mockito.anyBoolean());
+ Mockito.doReturn(retVal3).when(roleDAO).readChildren(trans, "test", "test");
+
Identity iden=Mockito.mock(Identity.class);
try {
Mockito.doReturn(iden).when(org).getIdentity(trans, "test");
@@ -537,27 +537,27 @@ public class JU_Function {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
Mockito.doReturn(Result.err(Result.ERR_NotFound, "Not Found")).when(roleDAO).read(trans, "test","test");
Mockito.doReturn(Result.err(Result.ERR_NotFound, "Not Found")).when(permDAO).readByType(trans, "test","test");
Function funcObj = new Function(trans, ques);
Result<Void> result = funcObj.createNS(trans, namespace, true);
assertTrue(result.status == 0);
-
+
}
-
+
@Test
public void test4DeleteNs() {
Result<Void> retVal = new Result<Void>(null,1,"test",NO_PARAM);
- Mockito.doReturn(retVal).when(nsDAO).read(Mockito.any(), Mockito.anyString());
-
+ Mockito.doReturn(retVal).when(nsDAO).read(Mockito.any(), Mockito.anyString());
+
Function funcObj = new Function(trans, ques);
Result<Void> result = funcObj.deleteNS(trans, "test");
-
+
assertTrue(result.status == Status.ERR_NsNotFound);
}
-
+
@Test
public void test4DeleteCanMoveFail() {
List<NsDAO.Data> dataAl = new ArrayList<NsDAO.Data>();
@@ -565,17 +565,17 @@ public class JU_Function {
dataObj.type=1;
dataAl.add(dataObj);
Result<List<NsDAO.Data>> retVal = new Result<List<NsDAO.Data>>(dataAl,0,"test",NO_PARAM);
- Mockito.doReturn(retVal).when(nsDAO).read(Mockito.any(), Mockito.anyString());
-
+ Mockito.doReturn(retVal).when(nsDAO).read(Mockito.any(), Mockito.anyString());
+
Mockito.doReturn(false).when(ques).canMove(Mockito.any());
Mockito.doReturn(retVal).when(ques).mayUser(trans, null,retVal.value.get(0), Access.write);
-
+
Function funcObj = new Function(trans, ques);
Result<Void> result = funcObj.deleteNS(trans, "test");
assertTrue(result.status == Status.ERR_Security);
-
+
}
-
+
@Test
public void test4DeleteNsReadSuc() {
List<NsDAO.Data> dataAl = new ArrayList<NsDAO.Data>();
@@ -583,17 +583,17 @@ public class JU_Function {
dataObj.type=1;
dataAl.add(dataObj);
Result<List<NsDAO.Data>> retVal = new Result<List<NsDAO.Data>>(dataAl,0,"test",NO_PARAM);
- Mockito.doReturn(retVal).when(nsDAO).read(Mockito.any(), Mockito.anyString());
-
+ Mockito.doReturn(retVal).when(nsDAO).read(Mockito.any(), Mockito.anyString());
+
Result<NsDAO.Data> retVal2 = new Result<NsDAO.Data>(null,1,"test",NO_PARAM);
Mockito.doReturn(retVal2).when(ques).mayUser(trans, null,retVal.value.get(0), Access.write);
-
+
Function funcObj = new Function(trans, ques);
Result<Void> result = funcObj.deleteNS(trans, "test");
assertTrue(result.status == 1);
-
+
}
-
+
@Test
public void test4DeleteNsMayUserSuc() {
List<NsDAO.Data> dataAl = new ArrayList<NsDAO.Data>();
@@ -601,22 +601,22 @@ public class JU_Function {
dataObj.type=1;
dataAl.add(dataObj);
Result<List<NsDAO.Data>> retVal = new Result<List<NsDAO.Data>>(dataAl,0,"test",NO_PARAM);
- Mockito.doReturn(retVal).when(nsDAO).read(Mockito.any(), Mockito.anyString());
-
+ Mockito.doReturn(retVal).when(nsDAO).read(Mockito.any(), Mockito.anyString());
+
Result<NsDAO.Data> retVal2 = new Result<NsDAO.Data>(null,0,"test",NO_PARAM);
Mockito.doReturn(retVal2).when(ques).mayUser(trans, null,retVal.value.get(0), Access.write);
-
+
Function funcObj = new Function(trans, ques);
Result<Void> result = funcObj.deleteNS(trans, "test");
assertTrue(result.status == 1);
Mockito.doReturn(true).when(ques).isGranted(Mockito.any(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString());
- Mockito.doReturn(retVal2).when(credDAO).readNS(Mockito.any(), Mockito.anyString());
+ Mockito.doReturn(retVal2).when(credDAO).readNS(Mockito.any(), Mockito.anyString());
Result<List<PermDAO.Data>> retVal5 = new Result<List<PermDAO.Data>>(null,0,"test",NO_PARAM);
Mockito.doReturn(retVal5).when(permDAO).readNS(trans, "test");
-
+
List<UserRoleDAO.Data> dataObj4 = new ArrayList<>();
UserRoleDAO.Data indData4 = new UserRoleDAO.Data();
indData4.ns = "test";
@@ -624,7 +624,7 @@ public class JU_Function {
dataObj4.add(indData4);
Result<List<UserRoleDAO.Data>> retVal4 = new Result<List<UserRoleDAO.Data>>(dataObj4,0,"test",NO_PARAM);
Mockito.doReturn(retVal4).when(userRoleDAO).readByRole(trans, "test");
-
+
List<RoleDAO.Data> dataObj1 = new ArrayList<>();
RoleDAO.Data indData1 = new RoleDAO.Data();
indData1.ns = "test";
@@ -634,15 +634,15 @@ public class JU_Function {
indData1.perms = permsSet;
dataObj1.add(indData1);
Result<List<RoleDAO.Data>> retVal3 = new Result<List<RoleDAO.Data>>(dataObj1,0,"test",NO_PARAM);
- Mockito.doReturn(retVal3).when(roleDAO).readNS(trans, "test");
+ Mockito.doReturn(retVal3).when(roleDAO).readNS(trans, "test");
Mockito.doReturn(retVal3).when(roleDAO).read(trans, indData1);
-
+
funcObj = new Function(trans, ques);
result = funcObj.deleteNS(trans, "test");
assertTrue(result.status == Status.ERR_DependencyExists);
-
- Mockito.doReturn(retVal4).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
-
+
+ Mockito.doReturn(retVal4).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
+
Mockito.doReturn(true).when(trans).requested(REQD_TYPE.force);
funcObj = new Function(trans, ques);
result = funcObj.deleteNS(trans, "test");
@@ -655,18 +655,18 @@ public class JU_Function {
dataObj.type=1;
dataAl.add(dataObj);
Result<List<NsDAO.Data>> retVal = new Result<List<NsDAO.Data>>(dataAl,0,"test",NO_PARAM);
- Mockito.doReturn(retVal).when(nsDAO).read(Mockito.any(), Mockito.anyString());
-
+ Mockito.doReturn(retVal).when(nsDAO).read(Mockito.any(), Mockito.anyString());
+
Result<NsDAO.Data> retVal2 = new Result<NsDAO.Data>(null,0,"test",NO_PARAM);
Mockito.doReturn(retVal2).when(ques).mayUser(trans, null,retVal.value.get(0), Access.write);
-
+
Function funcObj = new Function(trans, ques);
Result<Void> result = funcObj.deleteNS(trans, "test");
assertTrue(result.status == 1);
Mockito.doReturn(true).when(ques).isGranted(Mockito.any(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString());
- Mockito.doReturn(retVal2).when(credDAO).readNS(Mockito.any(), Mockito.anyString());
+ Mockito.doReturn(retVal2).when(credDAO).readNS(Mockito.any(), Mockito.anyString());
List<PermDAO.Data> dataObj5 = new ArrayList<>();
PermDAO.Data indData5 = new PermDAO.Data();
@@ -677,8 +677,8 @@ public class JU_Function {
Mockito.doReturn(retVal5).when(permDAO).readNS(trans, "test");
Mockito.doReturn(retVal5).when(permDAO).readNS(trans, "test.test");
Mockito.doReturn(retVal5).when(permDAO).read(trans, indData5);
-
-
+
+
List<RoleDAO.Data> dataObj1 = new ArrayList<>();
RoleDAO.Data indData1 = new RoleDAO.Data();
indData1.ns = "test";
@@ -688,19 +688,19 @@ public class JU_Function {
indData1.perms = permsSet;
dataObj1.add(indData1);
Result<List<RoleDAO.Data>> retVal3 = new Result<List<RoleDAO.Data>>(dataObj1,0,"test",NO_PARAM);
- Mockito.doReturn(retVal3).when(roleDAO).readNS(trans, "test");
- Mockito.doReturn(retVal3).when(roleDAO).readNS(trans, "test.test");
+ Mockito.doReturn(retVal3).when(roleDAO).readNS(trans, "test");
+ Mockito.doReturn(retVal3).when(roleDAO).readNS(trans, "test.test");
Mockito.doReturn(retVal3).when(roleDAO).read(trans, indData1);
-
+
funcObj = new Function(trans, ques);
result = funcObj.deleteNS(trans, "test");
assertTrue(result.status == Status.ERR_DependencyExists);
-
+
NsDAO.Data data = new NsDAO.Data();
data.name="test";
Result<NsDAO.Data> retVal1 = new Result<NsDAO.Data>(data,1,"test",NO_PARAM);
Mockito.doReturn(retVal1).when(ques).deriveNs(trans, "test");
-
+
Mockito.doReturn(true).when(trans).requested(REQD_TYPE.force);
funcObj = new Function(trans, ques);
result = funcObj.deleteNS(trans, "test.test");
@@ -714,8 +714,8 @@ public class JU_Function {
dataObj.type=1;
dataAl.add(dataObj);
Result<List<NsDAO.Data>> retVal = new Result<List<NsDAO.Data>>(dataAl,0,"test",NO_PARAM);
- Mockito.doReturn(retVal).when(nsDAO).read(Mockito.any(), Mockito.anyString());
-
+ Mockito.doReturn(retVal).when(nsDAO).read(Mockito.any(), Mockito.anyString());
+
List<CredDAO.Data> nsDataList = new ArrayList<CredDAO.Data>();
CredDAO.Data nsData = new CredDAO.Data();
nsData.id="test";
@@ -723,15 +723,15 @@ public class JU_Function {
Result<List<CredDAO.Data>> retVal21 = new Result<List<CredDAO.Data>>(nsDataList,0,"test",NO_PARAM);
Result<NsDAO.Data> retVal2 = new Result<NsDAO.Data>(null,0,"test",NO_PARAM);
Mockito.doReturn(retVal2).when(ques).mayUser(trans, null,retVal.value.get(0), Access.write);
-
+
Function funcObj = new Function(trans, ques);
Result<Void> result = funcObj.deleteNS(trans, "test");
assertTrue(result.status == 1);
Mockito.doReturn(true).when(ques).isGranted(Mockito.any(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString());
- Mockito.doReturn(retVal21).when(credDAO).readNS(Mockito.any(), Mockito.anyString());
- Mockito.doReturn(retVal21).when(credDAO).delete(Mockito.any(), Mockito.any(), Mockito.anyBoolean());
+ Mockito.doReturn(retVal21).when(credDAO).readNS(Mockito.any(), Mockito.anyString());
+ Mockito.doReturn(retVal21).when(credDAO).delete(Mockito.any(), Mockito.any(), Mockito.anyBoolean());
List<PermDAO.Data> dataObj5 = new ArrayList<>();
PermDAO.Data indData5 = new PermDAO.Data();
@@ -742,7 +742,7 @@ public class JU_Function {
Mockito.doReturn(retVal5).when(permDAO).readNS(trans, "test");
Mockito.doReturn(retVal5).when(permDAO).readNS(trans, "test.test");
Mockito.doReturn(retVal5).when(permDAO).read(trans, indData5);
-
+
List<UserRoleDAO.Data> dataObj4 = new ArrayList<>();
UserRoleDAO.Data indData4 = new UserRoleDAO.Data();
indData4.ns = "test";
@@ -751,7 +751,7 @@ public class JU_Function {
Result<List<UserRoleDAO.Data>> retVal4 = new Result<List<UserRoleDAO.Data>>(dataObj4,0,"test",NO_PARAM);
Mockito.doReturn(retVal4).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
Mockito.doReturn(retVal4).when(userRoleDAO).readByUser(Mockito.any(), Mockito.anyString());
-
+
List<RoleDAO.Data> dataObj1 = new ArrayList<>();
RoleDAO.Data indData1 = new RoleDAO.Data();
indData1.ns = "test";
@@ -761,25 +761,25 @@ public class JU_Function {
indData1.perms = permsSet;
dataObj1.add(indData1);
Result<List<RoleDAO.Data>> retVal3 = new Result<List<RoleDAO.Data>>(dataObj1,0,"test",NO_PARAM);
- Mockito.doReturn(retVal3).when(roleDAO).readNS(trans, "test");
- Mockito.doReturn(retVal3).when(roleDAO).readNS(trans, "test.test");
+ Mockito.doReturn(retVal3).when(roleDAO).readNS(trans, "test");
+ Mockito.doReturn(retVal3).when(roleDAO).readNS(trans, "test.test");
Mockito.doReturn(retVal3).when(roleDAO).read(trans, indData1);
-
+
funcObj = new Function(trans, ques);
result = funcObj.deleteNS(trans, "test");
assertTrue(result.status == Status.ERR_DependencyExists);
-
+
NsDAO.Data data = new NsDAO.Data();
data.name="test";
Result<NsDAO.Data> retVal1 = new Result<NsDAO.Data>(data,0,"test",NO_PARAM);
Mockito.doReturn(retVal1).when(ques).deriveNs(trans, "test");
-
+
Mockito.doReturn(true).when(trans).requested(REQD_TYPE.force);
funcObj = new Function(trans, ques);
result = funcObj.deleteNS(trans, "test.test");
assertNull(result);
}
-
+
@Test
public void testGetOwners() {
// List<NsDAO.Data> dataAl = new ArrayList<NsDAO.Data>();
@@ -787,49 +787,49 @@ public class JU_Function {
// dataObj.type=1;
// dataAl.add(dataObj);
Result<List<UserRoleDAO.Data>> retVal = new Result<List<UserRoleDAO.Data>>(null,1,"test",NO_PARAM);
- Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
-//
+ Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
+//
// Result<NsDAO.Data> retVal2 = new Result<NsDAO.Data>(null,0,"test",NO_PARAM);
// Mockito.doReturn(retVal2).when(ques).mayUser(trans, null,retVal.value.get(0), Access.write);
-//
+//
Function funcObj = new Function(trans, ques);
Result<List<String>> result = funcObj.getOwners(trans, "test", false);
assertTrue(result.status == 1);
-//
+//
}
-
+
@Test
public void testDelOwner() {
Result<List<UserRoleDAO.Data>> retVal = new Result<List<UserRoleDAO.Data>>(null,1,"test",NO_PARAM);
- Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
- Mockito.doReturn(retVal).when(userRoleDAO).read(Mockito.any(), Mockito.any( UserRoleDAO.Data.class));
+ Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
+ Mockito.doReturn(retVal).when(userRoleDAO).read(Mockito.any(), Mockito.any( UserRoleDAO.Data.class));
NsDAO.Data data = new NsDAO.Data();
data.name="test";
Result<NsDAO.Data> retVal1 = new Result<NsDAO.Data>(data,0,"test",NO_PARAM);
Mockito.doReturn(retVal1).when(ques).deriveNs(trans, "test");
-
+
Result<NsDAO.Data> retVal2 = new Result<NsDAO.Data>(data,1,"test",NO_PARAM);
Mockito.doReturn(retVal2).when(ques).mayUser(trans, null,retVal1.value, Access.write);
-
+
Function funcObj = new Function(trans, ques);
Result<Void> result = funcObj.delOwner(trans, "test", "test");
assertTrue(result.status == 1);
-
+
retVal1 = new Result<NsDAO.Data>(data,1,"test",NO_PARAM);
Mockito.doReturn(retVal1).when(ques).deriveNs(trans, "test");
result = funcObj.delOwner(trans, "test", "test");
assertTrue(result.status == 1);
-
+
retVal1 = new Result<NsDAO.Data>(data,0,"test",NO_PARAM);
Mockito.doReturn(retVal1).when(ques).deriveNs(trans, "test");
result = funcObj.delOwner(trans, "test", "test");
retVal2 = new Result<NsDAO.Data>(data,0,"test",NO_PARAM);
Mockito.doReturn(retVal2).when(ques).mayUser(trans, null,retVal1.value, Access.write);
result = funcObj.delOwner(trans, "test", "test");
-//
+//
}
-
+
@Test
public void testGetAdmins() {
// List<NsDAO.Data> dataAl = new ArrayList<NsDAO.Data>();
@@ -837,49 +837,49 @@ public class JU_Function {
// dataObj.type=1;
// dataAl.add(dataObj);
Result<List<UserRoleDAO.Data>> retVal = new Result<List<UserRoleDAO.Data>>(null,1,"test",NO_PARAM);
- Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
-//
+ Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
+//
// Result<NsDAO.Data> retVal2 = new Result<NsDAO.Data>(null,0,"test",NO_PARAM);
// Mockito.doReturn(retVal2).when(ques).mayUser(trans, null,retVal.value.get(0), Access.write);
-//
+//
Function funcObj = new Function(trans, ques);
Result<List<String>> result = funcObj.getAdmins(trans, "test", false);
assertTrue(result.status == 1);
-//
+//
}
-
+
@Test
public void testDelAdmin() {
Result<List<UserRoleDAO.Data>> retVal = new Result<List<UserRoleDAO.Data>>(null,1,"test",NO_PARAM);
- Mockito.doReturn(retVal).when(userRoleDAO).readUserInRole(Mockito.any(), Mockito.anyString(), Mockito.anyString());
- Mockito.doReturn(retVal).when(userRoleDAO).read(Mockito.any(), Mockito.any( UserRoleDAO.Data.class));
+ Mockito.doReturn(retVal).when(userRoleDAO).readUserInRole(Mockito.any(), Mockito.anyString(), Mockito.anyString());
+ Mockito.doReturn(retVal).when(userRoleDAO).read(Mockito.any(), Mockito.any( UserRoleDAO.Data.class));
NsDAO.Data data = new NsDAO.Data();
data.name="test";
Result<NsDAO.Data> retVal1 = new Result<NsDAO.Data>(data,0,"test",NO_PARAM);
Mockito.doReturn(retVal1).when(ques).deriveNs(trans, "test");
-
+
Result<NsDAO.Data> retVal2 = new Result<NsDAO.Data>(data,1,"test",NO_PARAM);
Mockito.doReturn(retVal2).when(ques).mayUser(trans, null,retVal1.value, Access.write);
-
+
Function funcObj = new Function(trans, ques);
Result<Void> result = funcObj.delAdmin(trans, "test", "test");
assertTrue(result.status == 1);
-
+
retVal1 = new Result<NsDAO.Data>(data,1,"test",NO_PARAM);
Mockito.doReturn(retVal1).when(ques).deriveNs(trans, "test");
result = funcObj.delAdmin(trans, "test", "test");
assertTrue(result.status == 1);
-
+
retVal1 = new Result<NsDAO.Data>(data,0,"test",NO_PARAM);
Mockito.doReturn(retVal1).when(ques).deriveNs(trans, "test");
result = funcObj.delOwner(trans, "test", "test");
retVal2 = new Result<NsDAO.Data>(data,0,"test",NO_PARAM);
Mockito.doReturn(retVal2).when(ques).mayUser(trans, null,retVal1.value, Access.write);
result = funcObj.delAdmin(trans, "test", "test");
-//
+//
}
-
+
@Test
public void testMovePerms() {
// List<NsDAO.Data> dataAl = new ArrayList<NsDAO.Data>();
@@ -887,19 +887,19 @@ public class JU_Function {
// dataObj.type=1;
// dataAl.add(dataObj);
Result<List<UserRoleDAO.Data>> retVal = new Result<List<UserRoleDAO.Data>>(null,1,"test",NO_PARAM);
- Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
-
- Mockito.doReturn(retVal).when(roleDAO).delPerm(Mockito.any(), Mockito.any(), Mockito.any());
-
- Mockito.doReturn(retVal).when(permDAO).create(Mockito.any(), Mockito.any());
-
+ Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
+
+ Mockito.doReturn(retVal).when(roleDAO).delPerm(Mockito.any(), Mockito.any(), Mockito.any());
+
+ Mockito.doReturn(retVal).when(permDAO).create(Mockito.any(), Mockito.any());
+
NsDAO.Data nsDataObj = new NsDAO.Data();
nsDataObj.name="test";
StringBuilder sb = new StringBuilder();
Result<List<PermDAO.Data>> retVal1 = new Result<List<PermDAO.Data>>(null,1,"test",NO_PARAM);
-
+
invokeMovePerms(nsDataObj, sb, retVal1);
-
+
List<PermDAO.Data> dataObj5 = new ArrayList<>();
PermDAO.Data indData5 = new PermDAO.Data();
indData5.ns = "test";
@@ -915,25 +915,25 @@ public class JU_Function {
retVal1 = new Result<List<PermDAO.Data>>(dataObj5,0,"test",NO_PARAM);
Result<List<UserRoleDAO.Data>> retVal3 = new Result<List<UserRoleDAO.Data>>(null,0,"test",NO_PARAM);
- Mockito.doReturn(retVal3).when(permDAO).create(Mockito.any(), Mockito.any());
- Mockito.doReturn(retVal3).when(permDAO).delete(Mockito.any(), Mockito.any(), Mockito.anyBoolean());
+ Mockito.doReturn(retVal3).when(permDAO).create(Mockito.any(), Mockito.any());
+ Mockito.doReturn(retVal3).when(permDAO).delete(Mockito.any(), Mockito.any(), Mockito.anyBoolean());
NsSplit splitObj = new NsSplit("test", "test");
Result<NsSplit> retVal2 = new Result<NsSplit>(splitObj,0,"test",NO_PARAM);
Mockito.doReturn(retVal2).when(ques).deriveNsSplit(Mockito.any(), Mockito.anyString());
-
+
invokeMovePerms(nsDataObj, sb, retVal1);
-
+
Result<List<UserRoleDAO.Data>> retVal4 = new Result<List<UserRoleDAO.Data>>(null,1,"test",NO_PARAM);
- Mockito.doReturn(retVal4).when(permDAO).create(Mockito.any(), Mockito.any());
+ Mockito.doReturn(retVal4).when(permDAO).create(Mockito.any(), Mockito.any());
invokeMovePerms(nsDataObj, sb, retVal1);
-
- Mockito.doReturn(retVal3).when(permDAO).create(Mockito.any(), Mockito.any());
- Mockito.doReturn(retVal4).when(permDAO).delete(Mockito.any(), Mockito.any(), Mockito.anyBoolean());
+
+ Mockito.doReturn(retVal3).when(permDAO).create(Mockito.any(), Mockito.any());
+ Mockito.doReturn(retVal4).when(permDAO).delete(Mockito.any(), Mockito.any(), Mockito.anyBoolean());
invokeMovePerms(nsDataObj, sb, retVal1);
-
+
}
-
+
private void invokeMovePerms(NsDAO.Data nsDataObj, StringBuilder sb,Result<List<PermDAO.Data>> retVal1) {
Function funcObj = new Function(trans, ques);
Method met;
@@ -955,7 +955,7 @@ public class JU_Function {
e.printStackTrace();
}
}
-
+
@Test
public void testMoveRoles() {
// List<NsDAO.Data> dataAl = new ArrayList<NsDAO.Data>();
@@ -963,19 +963,19 @@ public class JU_Function {
// dataObj.type=1;
// dataAl.add(dataObj);
Result<List<UserRoleDAO.Data>> retVal = new Result<List<UserRoleDAO.Data>>(null,1,"test",NO_PARAM);
- Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
-
- Mockito.doReturn(retVal).when(roleDAO).delPerm(Mockito.any(), Mockito.any(), Mockito.any());
-
- Mockito.doReturn(retVal).when(roleDAO).create(Mockito.any(), Mockito.any());
-
+ Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
+
+ Mockito.doReturn(retVal).when(roleDAO).delPerm(Mockito.any(), Mockito.any(), Mockito.any());
+
+ Mockito.doReturn(retVal).when(roleDAO).create(Mockito.any(), Mockito.any());
+
NsDAO.Data nsDataObj = new NsDAO.Data();
nsDataObj.name="test";
StringBuilder sb = new StringBuilder();
Result<List<RoleDAO.Data>> retVal1 = new Result<List<RoleDAO.Data>>(null,1,"test",NO_PARAM);
-
+
invokeMoveRoles(nsDataObj, sb, retVal1);
-
+
List<RoleDAO.Data> dataObj5 = new ArrayList<>();
RoleDAO.Data indData5 = new RoleDAO.Data();
indData5.ns = "test";
@@ -989,27 +989,27 @@ public class JU_Function {
indData5.name = "admin";
dataObj5.add(indData5);
retVal1 = new Result<List<RoleDAO.Data>>(dataObj5,0,"test",NO_PARAM);
-
+
Result<List<UserRoleDAO.Data>> retVal3 = new Result<List<UserRoleDAO.Data>>(null,0,"test",NO_PARAM);
- Mockito.doReturn(retVal3).when(roleDAO).create(Mockito.any(), Mockito.any());
- Mockito.doReturn(retVal3).when(roleDAO).delete(Mockito.any(), Mockito.any(), Mockito.anyBoolean());
+ Mockito.doReturn(retVal3).when(roleDAO).create(Mockito.any(), Mockito.any());
+ Mockito.doReturn(retVal3).when(roleDAO).delete(Mockito.any(), Mockito.any(), Mockito.anyBoolean());
NsSplit splitObj = new NsSplit("test", "test");
Result<NsSplit> retVal2 = new Result<NsSplit>(splitObj,0,"test",NO_PARAM);
Mockito.doReturn(retVal2).when(ques).deriveNsSplit(Mockito.any(), Mockito.anyString());
-
+
invokeMoveRoles(nsDataObj, sb, retVal1);
-
+
Result<List<UserRoleDAO.Data>> retVal4 = new Result<List<UserRoleDAO.Data>>(null,1,"test",NO_PARAM);
- Mockito.doReturn(retVal4).when(roleDAO).create(Mockito.any(), Mockito.any());
+ Mockito.doReturn(retVal4).when(roleDAO).create(Mockito.any(), Mockito.any());
invokeMoveRoles(nsDataObj, sb, retVal1);
-
- Mockito.doReturn(retVal3).when(roleDAO).create(Mockito.any(), Mockito.any());
- Mockito.doReturn(retVal4).when(roleDAO).delete(Mockito.any(), Mockito.any(), Mockito.anyBoolean());
+
+ Mockito.doReturn(retVal3).when(roleDAO).create(Mockito.any(), Mockito.any());
+ Mockito.doReturn(retVal4).when(roleDAO).delete(Mockito.any(), Mockito.any(), Mockito.anyBoolean());
invokeMoveRoles(nsDataObj, sb, retVal1);
-
+
}
-
+
private void invokeMoveRoles(NsDAO.Data nsDataObj, StringBuilder sb,Result<List<RoleDAO.Data>> retVal1) {
Function funcObj = new Function(trans, ques);
Method met;
@@ -1031,7 +1031,7 @@ public class JU_Function {
e.printStackTrace();
}
}
-
+
@Test
public void testCreatePerm() {
try {
@@ -1049,20 +1049,20 @@ public class JU_Function {
dataAl.add(perm);
Result<List<UserRoleDAO.Data>> retVal = new Result<List<UserRoleDAO.Data>>(null,1,"test",NO_PARAM);
Mockito.doReturn(retVal).when(ques).deriveNsSplit(Mockito.any(), Mockito.anyString());
-
- Mockito.doReturn(retVal).when(userRoleDAO).read(Mockito.any(), Mockito.any(UserRoleDAO.Data.class));
- Mockito.doReturn(retVal).when(userRoleDAO).create(Mockito.any(), Mockito.any(UserRoleDAO.Data.class));
-
+
+ Mockito.doReturn(retVal).when(userRoleDAO).read(Mockito.any(), Mockito.any(UserRoleDAO.Data.class));
+ Mockito.doReturn(retVal).when(userRoleDAO).create(Mockito.any(), Mockito.any(UserRoleDAO.Data.class));
+
Mockito.doReturn(retVal).when(permDAO).create(Mockito.any(), Mockito.any());
- Mockito.doReturn(retVal).when(permDAO).read(trans, perm);
-
+ Mockito.doReturn(retVal).when(permDAO).read(trans, perm);
+
Result<NsDAO.Data> retVal2 = new Result<NsDAO.Data>(null,1,"test",NO_PARAM);
Mockito.doReturn(retVal2).when(ques).mayUser(trans, null,perm, Access.write);
-
+
Function funcObj = new Function(trans, ques);
Result<Void> result = funcObj.createPerm(trans, perm, false);
assertTrue(result.status == 1);
-
+
retVal2 = new Result<NsDAO.Data>(null,0,"test",NO_PARAM);
Mockito.doReturn(retVal2).when(ques).mayUser(trans, null,perm, Access.write);
result = funcObj.createPerm(trans, perm, false);
@@ -1077,21 +1077,21 @@ public class JU_Function {
Result<List<RoleDAO.Data>> retVal4 = Result.err(Result.ERR_NotFound,"");
Mockito.doReturn(retVal4).when(roleDAO).create(Mockito.any(),Mockito.any(RoleDAO.Data.class));
result = funcObj.createPerm(trans, perm, false);
-
- Mockito.doReturn(retVal).when(permDAO).read(trans, perm);
+
+ Mockito.doReturn(retVal).when(permDAO).read(trans, perm);
result = funcObj.createPerm(trans, perm, true);
assertTrue(result.status == 1);
Mockito.doReturn(retVal2).when(permDAO).create(Mockito.any(), Mockito.any());
result = funcObj.createPerm(trans, perm, true);
assertTrue(result.status == 0);
-
+
Mockito.doReturn(false).when(trans).requested(REQD_TYPE.force);
Result<List<PermDAO.Data>> retVal1 = new Result<List<PermDAO.Data>>(dataAl,0,"test",NO_PARAM);
- Mockito.doReturn(retVal1).when(permDAO).read(trans, perm);
+ Mockito.doReturn(retVal1).when(permDAO).read(trans, perm);
result = funcObj.createPerm(trans, perm, true);
assertTrue(result.status == Status.ERR_ConflictAlreadyExists);
-
+
}
@Test
public void testDeletePerm() {
@@ -1108,24 +1108,24 @@ public class JU_Function {
perm.roles = rolesSet;
// perm.type=1
dataAl.add(perm);
-
+
Result<NsDAO.Data> retVal2 = new Result<NsDAO.Data>(null,1,"test",NO_PARAM);
Mockito.doReturn(retVal2).when(ques).mayUser(trans, null,perm, Access.write);
-
+
// List<NsDAO.Data> dataAl = new ArrayList<NsDAO.Data>();
// NsDAO.Data dataObj = new NsDAO.Data();
// dataObj.type=1;
// dataAl.add(dataObj);
Result<List<PermDAO.Data>> retVal = new Result<List<PermDAO.Data>>(dataAl,1,"test",NO_PARAM);
- Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
-
+ Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
+
Function funcObj = new Function(trans, ques);
Result<Void> result = funcObj.deletePerm(trans, perm, true,false);
assertTrue(result.status == 1);
// Mockito.doReturn(retVal).when(cachedPermDAO).create(Mockito.any(), Mockito.any());
- Mockito.doReturn(retVal).when(permDAO).read(trans, perm);
-
+ Mockito.doReturn(retVal).when(permDAO).read(trans, perm);
+
result = funcObj.deletePerm(trans, perm, true,true);
assertTrue(result.status == Status.ERR_PermissionNotFound);
@@ -1133,24 +1133,24 @@ public class JU_Function {
Mockito.doReturn(retVal2).when(ques).mayUser(trans, null,perm, Access.write);
Result<List<PermDAO.Data>> retVal3 = new Result<List<PermDAO.Data>>(dataAl,0,"test",NO_PARAM);
Mockito.doReturn(retVal3).when(permDAO).read(trans, perm);
-
+
NsSplit nsObj = new NsSplit("test","test");
Result<NsSplit> retValNs = new Result<NsSplit>(nsObj,0,"test",NO_PARAM);
Mockito.doReturn(retValNs).when(ques).deriveNsSplit(Mockito.any(), Mockito.anyString());
-
- Mockito.doReturn(retVal).when(roleDAO).delPerm(Mockito.any(), Mockito.any(), Mockito.any());
-
+
+ Mockito.doReturn(retVal).when(roleDAO).delPerm(Mockito.any(), Mockito.any(), Mockito.any());
+
result = funcObj.deletePerm(trans, perm, true,false);
- assertNull(result);
-
- Mockito.doReturn(retVal2).when(roleDAO).delPerm(Mockito.any(), Mockito.any(), Mockito.any());
+ assertNull(result);
+
+ Mockito.doReturn(retVal2).when(roleDAO).delPerm(Mockito.any(), Mockito.any(), Mockito.any());
result = funcObj.deletePerm(trans, perm, true,false);
- assertNull(result);
-
+ assertNull(result);
+
result = funcObj.deletePerm(trans, perm, false,false);
// assertTrue(result.status == 1);
}
-
+
@Test
public void testDeleteRole() {
try {
@@ -1167,7 +1167,7 @@ public class JU_Function {
// perm.roles = rolesSet;
// perm.type=1
dataAlUser.add(roleUser);
-
+
List<RoleDAO.Data> dataAl = new ArrayList<RoleDAO.Data>();
RoleDAO.Data role = new RoleDAO.Data();
Set<String> rolesSet = new HashSet<>();
@@ -1176,48 +1176,48 @@ public class JU_Function {
// perm.roles = rolesSet;
// perm.type=1
dataAl.add(role);
-
+
Result<NsDAO.Data> retVal2 = new Result<NsDAO.Data>(null,1,"test",NO_PARAM);
Mockito.doReturn(retVal2).when(ques).mayUser(trans, null,role, Access.write);
-
+
// List<NsDAO.Data> dataAl = new ArrayList<NsDAO.Data>();
// NsDAO.Data dataObj = new NsDAO.Data();
// dataObj.type=1;
// dataAl.add(dataObj);
Result<List<UserRoleDAO.Data>> retVal = new Result<List<UserRoleDAO.Data>>(null,1,"test",NO_PARAM);
- Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
-//
+ Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
+//
// Result<NsDAO.Data> retVal2 = new Result<NsDAO.Data>(null,0,"test",NO_PARAM);
// Mockito.doReturn(retVal2).when(ques).mayUser(trans, null,retVal.value.get(0), Access.write);
-//
+//
Function funcObj = new Function(trans, ques);
Result<Void> result = funcObj.deleteRole(trans, role, true, false);
assertTrue(result.status == 1);
Result<List<RoleDAO.Data>> retVal1 = new Result<List<RoleDAO.Data>>(dataAl,0,"test",NO_PARAM);
- Mockito.doReturn(retVal1).when(roleDAO).read(Mockito.any(), Mockito.any(RoleDAO.Data.class));
+ Mockito.doReturn(retVal1).when(roleDAO).read(Mockito.any(), Mockito.any(RoleDAO.Data.class));
NsSplit splitObj = new NsSplit("test", "test");
Result<NsSplit> retVal3 = new Result<NsSplit>(splitObj,0,"test",NO_PARAM);
Mockito.doReturn(retVal3).when(ques).deriveNsSplit(Mockito.any(), Mockito.anyString());
// Mockito.doReturn(retVal).when(cachedPermDAO).create(Mockito.any(), Mockito.any());
- Mockito.doReturn(retVal).when(permDAO).delRole(Mockito.any(), Mockito.any(),Mockito.any());
+ Mockito.doReturn(retVal).when(permDAO).delRole(Mockito.any(), Mockito.any(),Mockito.any());
result = funcObj.deleteRole(trans, role, true, true);
assertNull(result);
-
+
Mockito.doReturn(retVal1).when(permDAO).delRole(Mockito.any(), Mockito.any(),Mockito.any());
result = funcObj.deleteRole(trans, role, true, true);
assertNull(result);
- Mockito.doReturn(retVal).when(roleDAO).read(Mockito.any(), Mockito.any(RoleDAO.Data.class));
+ Mockito.doReturn(retVal).when(roleDAO).read(Mockito.any(), Mockito.any(RoleDAO.Data.class));
result = funcObj.deleteRole(trans, role, true, true);
assertTrue(result.status == Status.ERR_RoleNotFound);
-
+
retVal = new Result<List<UserRoleDAO.Data>>(dataAlUser,0,"test",NO_PARAM);
- Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
+ Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
result = funcObj.deleteRole(trans, role, false, true);
assertTrue(result.status == Status.ERR_DependencyExists);
}
-
+
@Test
public void testAddPermToRole() {
List<PermDAO.Data> dataAlPerm = new ArrayList<PermDAO.Data>();
@@ -1227,7 +1227,7 @@ public class JU_Function {
// perm.roles = rolesSet;
// perm.type=1
dataAlPerm.add(rolePerm);
-
+
List<RoleDAO.Data> dataAl = new ArrayList<RoleDAO.Data>();
RoleDAO.Data role = new RoleDAO.Data();
Set<String> rolesSet = new HashSet<>();
@@ -1236,27 +1236,27 @@ public class JU_Function {
// perm.roles = rolesSet;
// perm.type=1
dataAl.add(role);
-
+
NsDAO.Data nsObj = new NsDAO.Data();
nsObj.name="test";
NsDAO.Data nsObj1 = new NsDAO.Data();
nsObj1.name="test12";
-
+
// List<NsDAO.Data> dataAl = new ArrayList<NsDAO.Data>();
// NsDAO.Data dataObj = new NsDAO.Data();
// dataObj.type=1;
// dataAl.add(dataObj);
Result<List<UserRoleDAO.Data>> retVal = new Result<List<UserRoleDAO.Data>>(null,1,"test",NO_PARAM);
- Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
+ Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
Result<NsDAO.Data> retVal2 = new Result<NsDAO.Data>(nsObj,0,"test",NO_PARAM);
Mockito.doReturn(retVal2).when(ques).deriveFirstNsForType(trans, role.ns, NsType.COMPANY);
Mockito.doReturn(retVal2).when(ques).deriveFirstNsForType(trans, rolePerm.ns, NsType.COMPANY);
-
+
Result<NsDAO.Data> retVal3 = new Result<NsDAO.Data>(null,1,"test",NO_PARAM);
Mockito.doReturn(retVal3).when(ques).mayUser(trans, null,rolePerm, Access.write);
Mockito.doReturn(retVal3).when(ques).mayUser(trans, null,role, Access.write);
-
+
Function funcObj = new Function(trans, ques);
Result<Void> result = funcObj.addPermToRole(trans, role, rolePerm, false);
assertTrue(result.status == 1);
@@ -1266,62 +1266,62 @@ public class JU_Function {
Mockito.doReturn(retVal2).when(ques).deriveFirstNsForType(trans, rolePerm.ns, NsType.COMPANY);
result = funcObj.addPermToRole(trans, role, rolePerm, false);
assertTrue(result.status == 1);
-
+
role.ns="test2";
retVal2 = new Result<NsDAO.Data>(nsObj,0,"test",NO_PARAM);
Mockito.doReturn(retVal2).when(ques).deriveFirstNsForType(trans, role.ns, NsType.COMPANY);
result = funcObj.addPermToRole(trans, role, rolePerm, false);
assertTrue(result.status == 1);
-
+
retVal2 = new Result<NsDAO.Data>(nsObj,0,"test1",NO_PARAM);
Mockito.doReturn(retVal2).when(ques).deriveFirstNsForType(trans, role.ns, NsType.COMPANY);
Result<NsDAO.Data> retVal21 = new Result<NsDAO.Data>(nsObj1,0,"test1",NO_PARAM);
Mockito.doReturn(retVal21).when(ques).deriveFirstNsForType(trans, rolePerm.ns, NsType.COMPANY);
result = funcObj.addPermToRole(trans, role, rolePerm, false);
assertTrue(result.status == 1);
-
+
retVal3 = new Result<NsDAO.Data>(null,0,"test",NO_PARAM);
Mockito.doReturn(retVal3).when(ques).mayUser(trans, null,rolePerm, Access.write);
retVal2 = new Result<NsDAO.Data>(nsObj,0,"test1",NO_PARAM);
Mockito.doReturn(retVal2).when(ques).deriveFirstNsForType(trans, role.ns, NsType.COMPANY);
Mockito.doReturn(retVal2).when(ques).deriveFirstNsForType(trans, rolePerm.ns, NsType.COMPANY);
-
+
// Mockito.doReturn(retVal).when(cachedPermDAO).create(Mockito.any(), Mockito.any());
- Mockito.doReturn(retVal).when(permDAO).read(Mockito.any(), Mockito.any(PermDAO.Data.class));
-
+ Mockito.doReturn(retVal).when(permDAO).read(Mockito.any(), Mockito.any(PermDAO.Data.class));
+
result = funcObj.addPermToRole(trans, role, rolePerm, false);
assertTrue(result.status == Status.ERR_PermissionNotFound);
-
+
Result<List<PermDAO.Data>> retValPerm= new Result<List<PermDAO.Data>>(dataAlPerm,0,"test1",NO_PARAM);
- Mockito.doReturn(retValPerm).when(permDAO).read(Mockito.any(), Mockito.any(PermDAO.Data.class));
-
+ Mockito.doReturn(retValPerm).when(permDAO).read(Mockito.any(), Mockito.any(PermDAO.Data.class));
+
Mockito.doReturn(retVal3).when(roleDAO).read(trans, role);
-
+
result = funcObj.addPermToRole(trans, role, rolePerm, true);
assertTrue(result.status == 22);
Mockito.doReturn(true).when(trans).requested(REQD_TYPE.force);
result = funcObj.addPermToRole(trans, role, rolePerm, true);
assertTrue(result.status == 2);
-
+
retVal3 = new Result<NsDAO.Data>(null,0,"test",NO_PARAM);
Mockito.doReturn(retVal3).when(ques).mayUser(trans, null,role, Access.write);
Mockito.doReturn(retVal3).when(roleDAO).create(trans, role);
result = funcObj.addPermToRole(trans, role, rolePerm, true);
// System.out.println(result.status);
assertNull(result);
-
+
retVal3 = new Result<NsDAO.Data>(null,1,"test",NO_PARAM);
Mockito.doReturn(retVal3).when(roleDAO).create(trans, role);
result = funcObj.addPermToRole(trans, role, rolePerm, true);
assertTrue(result.status == 1);
-
+
Result<List<RoleDAO.Data>> retVal31 = new Result<List<RoleDAO.Data>>(dataAl,0,"test",NO_PARAM);
Mockito.doReturn(retVal31).when(roleDAO).read(trans, role);
result = funcObj.addPermToRole(trans, role, rolePerm, true);
assertTrue(result.status == 7);
}
-
+
@Test
public void testDelPermFromRole() {
List<PermDAO.Data> dataAlPerm = new ArrayList<PermDAO.Data>();
@@ -1331,78 +1331,78 @@ public class JU_Function {
// perm.roles = rolesSet;
// perm.type=1
dataAlPerm.add(rolePerm);
-
+
List<RoleDAO.Data> dataAl = new ArrayList<RoleDAO.Data>();
RoleDAO.Data role = new RoleDAO.Data();
Set<String> rolesSet = new HashSet<>();
rolesSet.add("17623");
role.perms = rolesSet;
dataAl.add(role);
-
+
// List<NsDAO.Data> dataAl = new ArrayList<NsDAO.Data>();
// NsDAO.Data dataObj = new NsDAO.Data();
// dataObj.type=1;
// dataAl.add(dataObj);
Result<List<UserRoleDAO.Data>> retVal = new Result<List<UserRoleDAO.Data>>(null,1,"test",NO_PARAM);
- Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
+ Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
Result<NsDAO.Data> retValFail = new Result<NsDAO.Data>(null,1,"test",NO_PARAM);
Result<NsDAO.Data> retValSuc = new Result<NsDAO.Data>(null,0,"test",NO_PARAM);
Mockito.doReturn(retValFail).when(ques).mayUser(trans, null,rolePerm, Access.write);
Mockito.doReturn(retValFail).when(ques).mayUser(trans, null,role, Access.write);
-
+
Function funcObj = new Function(trans, ques);
Result<Void> result = funcObj.delPermFromRole(trans, role, rolePerm, false);
assertTrue(result.status == Status.ERR_Denied);
-
+
Mockito.doReturn(retValFail).when(ques).mayUser(trans, null,rolePerm, Access.write);
- Mockito.doReturn(retValSuc).when(ques).mayUser(trans, null,role, Access.write);
-
+ Mockito.doReturn(retValSuc).when(ques).mayUser(trans, null,role, Access.write);
+
Mockito.doReturn(retValFail).when(roleDAO).read(trans, role);
-
- Mockito.doReturn(retVal).when(permDAO).read(Mockito.any(), Mockito.any(PermDAO.Data.class));
-
+
+ Mockito.doReturn(retVal).when(permDAO).read(Mockito.any(), Mockito.any(PermDAO.Data.class));
+
result = funcObj.delPermFromRole(trans, role, rolePerm, false);
assertTrue(result.status == 1);
-
+
Result<List<PermDAO.Data>> retValPermSuc = new Result<List<PermDAO.Data>>(dataAlPerm,0,"test",NO_PARAM);
- Mockito.doReturn(retValPermSuc).when(permDAO).read(Mockito.any(), Mockito.any(PermDAO.Data.class));
+ Mockito.doReturn(retValPermSuc).when(permDAO).read(Mockito.any(), Mockito.any(PermDAO.Data.class));
result = funcObj.delPermFromRole(trans, role, rolePerm, false);
assertTrue(result.status == 1);
-
+
Result<List<RoleDAO.Data>> retValRoleSuc = new Result<List<RoleDAO.Data>>(dataAl,0,"test",NO_PARAM);
- Mockito.doReturn(retValRoleSuc).when(roleDAO).read(Mockito.any(), Mockito.any(RoleDAO.Data.class));
+ Mockito.doReturn(retValRoleSuc).when(roleDAO).read(Mockito.any(), Mockito.any(RoleDAO.Data.class));
result = funcObj.delPermFromRole(trans, role, rolePerm, true);
assertTrue(result.status == Status.ERR_PermissionNotFound);
-
+
role.perms = null;
dataAl.add(role);
rolesSet.add("null|null|null|null");
role.perms = rolesSet;
dataAl.add(role);
- Mockito.doReturn(retValRoleSuc).when(roleDAO).read(Mockito.any(), Mockito.any(RoleDAO.Data.class));
- Mockito.doReturn(retVal).when(permDAO).delRole(Mockito.any(), Mockito.any(),Mockito.any(RoleDAO.Data.class));
+ Mockito.doReturn(retValRoleSuc).when(roleDAO).read(Mockito.any(), Mockito.any(RoleDAO.Data.class));
+ Mockito.doReturn(retVal).when(permDAO).delRole(Mockito.any(), Mockito.any(),Mockito.any(RoleDAO.Data.class));
result = funcObj.delPermFromRole(trans, role, rolePerm, true);
assertTrue(result.status == 1);
-
- Mockito.doReturn(true).when(trans).requested(REQD_TYPE.force);
+
+ Mockito.doReturn(true).when(trans).requested(REQD_TYPE.force);
result = funcObj.delPermFromRole(trans, role, rolePerm, true);
assertTrue(result.status == 1);
-
+
Mockito.doReturn(retValRoleSuc).when(permDAO).delRole(Mockito.any(), Mockito.any(),Mockito.any(RoleDAO.Data.class));
- Mockito.doReturn(retVal).when(roleDAO).delPerm(Mockito.any(), Mockito.any(),Mockito.any(PermDAO.Data.class));
+ Mockito.doReturn(retVal).when(roleDAO).delPerm(Mockito.any(), Mockito.any(),Mockito.any(PermDAO.Data.class));
result = funcObj.delPermFromRole(trans, role, rolePerm, true);
assertTrue(result.status == 1);
-
- Mockito.doReturn(retValPermSuc).when(roleDAO).delPerm(Mockito.any(), Mockito.any(),Mockito.any(PermDAO.Data.class));
+
+ Mockito.doReturn(retValPermSuc).when(roleDAO).delPerm(Mockito.any(), Mockito.any(),Mockito.any(PermDAO.Data.class));
result = funcObj.delPermFromRole(trans, role, rolePerm, true);
assertTrue(result.status == 0);
-
+
Mockito.doReturn(retVal).when(permDAO).read(Mockito.any(), Mockito.any(PermDAO.Data.class));
result = funcObj.delPermFromRole(trans, role, rolePerm, true);
assertTrue(result.status == 0);
-
- Mockito.doReturn(retVal).when(roleDAO).delPerm(Mockito.any(), Mockito.any(),Mockito.any(PermDAO.Data.class));
+
+ Mockito.doReturn(retVal).when(roleDAO).delPerm(Mockito.any(), Mockito.any(),Mockito.any(PermDAO.Data.class));
result = funcObj.delPermFromRole(trans, role, rolePerm, true);
assertTrue(result.status == 1);
@@ -1413,7 +1413,7 @@ public class JU_Function {
Mockito.doReturn(retValFail).when(ques).mayUser(Mockito.any(), Mockito.anyString(),Mockito.any(PermDAO.Data.class), Mockito.any());
result = funcObj.delPermFromRole(trans, "test", rolePerm);
assertTrue(result.status == 2);
-
+
retVal3 = new Result<NsSplit>(null,1,"test",NO_PARAM);
Mockito.doReturn(retVal3).when(ques).deriveNsSplit(Mockito.any(), Mockito.anyString());
result = funcObj.delPermFromRole(trans, "test", rolePerm);
@@ -1427,29 +1427,29 @@ public class JU_Function {
urData.rname="test";
urData.user="test";
urDataAl.add(urData);
-
+
Organization org = Mockito.mock(Organization.class);
Mockito.doReturn(org).when(trans).org();
Mockito.doReturn(Mockito.mock(GregorianCalendar.class)).when(org).expiration(Mockito.any(), Mockito.any(), Mockito.anyString());
-
+
Result<List<UserRoleDAO.Data>> retVal = new Result<List<UserRoleDAO.Data>>(null,1,"test",NO_PARAM);
Result<List<UserRoleDAO.Data>> retValSuc = new Result<List<UserRoleDAO.Data>>(urDataAl,0,"test",NO_PARAM);
Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
Mockito.doReturn(retVal).when(userRoleDAO).read(Mockito.any(), Mockito.any(UserRoleDAO.Data.class));
- Mockito.doReturn(retVal).when(userRoleDAO).create(Mockito.any(), Mockito.any(UserRoleDAO.Data.class));
- Mockito.doReturn(retValSuc).when(roleDAO).read(Mockito.any(), Mockito.anyString(), Mockito.anyString());
+ Mockito.doReturn(retVal).when(userRoleDAO).create(Mockito.any(), Mockito.any(UserRoleDAO.Data.class));
+ Mockito.doReturn(retValSuc).when(roleDAO).read(Mockito.any(), Mockito.anyString(), Mockito.anyString());
Result<List<CredDAO.Data>> retVal2 = new Result<List<CredDAO.Data>>(null,1,"test",NO_PARAM);
- Mockito.doReturn(retVal2).when(credDAO).readID(Mockito.any(), Mockito.anyString());
-
+ Mockito.doReturn(retVal2).when(credDAO).readID(Mockito.any(), Mockito.anyString());
+
Function funcObj = new Function(trans, ques);
Result<Void> result = funcObj.addUserRole(trans, urData);
assertTrue(result.status == 1);
-
+
urData.rname=Question.ADMIN;
result = funcObj.addUserRole(trans, urData);
assertTrue(result.status == 1);
-
+
NsDAO.Data data = new NsDAO.Data();
data.name="test";
Result<NsDAO.Data> retVal1 = new Result<NsDAO.Data>(data,0,"test",NO_PARAM);
@@ -1465,21 +1465,21 @@ public class JU_Function {
result = funcObj.addUserRole(trans, urData);
assertTrue(result.status == 1);
- Mockito.doReturn(retValSuc).when(userRoleDAO).create(Mockito.any(), Mockito.any(UserRoleDAO.Data.class));
+ Mockito.doReturn(retValSuc).when(userRoleDAO).create(Mockito.any(), Mockito.any(UserRoleDAO.Data.class));
result = funcObj.addUserRole(trans, urData);
assertTrue(result.status == 0);
Mockito.doReturn(retVal).when(roleDAO).read(Mockito.any(), Mockito.anyString(), Mockito.anyString());
result = funcObj.addUserRole(trans, urData);
assertTrue(result.status == Status.ERR_RoleNotFound);
-
+
Mockito.doReturn(retValSuc).when(userRoleDAO).read(Mockito.any(), Mockito.any(UserRoleDAO.Data.class));
result = funcObj.addUserRole(trans, urData);
assertTrue(result.status == Status.ERR_ConflictAlreadyExists);
-
+
result = funcObj.addUserRole(trans, "test", "test", "test");
assertTrue(result.status == 1);
-
+
try {
Mockito.doReturn(null).when(org).getIdentity(trans, "test");
} catch (OrganizationException e) {
@@ -1488,7 +1488,7 @@ public class JU_Function {
}
result = funcObj.addUserRole(trans, "test", "test", "test");
assertTrue(result.status == Result.ERR_BadData);
-
+
try {
Mockito.doThrow(OrganizationException.class).when(org).getIdentity(trans, "test");
} catch (OrganizationException e) {
@@ -1498,7 +1498,7 @@ public class JU_Function {
result = funcObj.addUserRole(trans, "test", "test", "test");
assertTrue(result.status == 20);
}
-
+
@Test
public void testExtendUserRole() {
List<UserRoleDAO.Data> urDataAl = new ArrayList<>();
@@ -1508,34 +1508,34 @@ public class JU_Function {
urData.user="test";
urData.expires=new Date();
urDataAl.add(urData);
-
+
// List<NsDAO.Data> dataAl = new ArrayList<NsDAO.Data>();
// NsDAO.Data dataObj = new NsDAO.Data();
// dataObj.type=1;
// dataAl.add(dataObj);
Result<List<UserRoleDAO.Data>> retVal = new Result<List<UserRoleDAO.Data>>(null,1,"test",NO_PARAM);
Result<List<UserRoleDAO.Data>> retValSuc = new Result<List<UserRoleDAO.Data>>(urDataAl,0,"test",NO_PARAM);
- Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
+ Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
Mockito.doReturn(retValSuc).when(roleDAO).read(Mockito.any(), Mockito.anyString(), Mockito.anyString());
Organization org = Mockito.mock(Organization.class);
Mockito.doReturn(org).when(trans).org();
Mockito.doReturn(Mockito.mock(GregorianCalendar.class)).when(org).expiration(Mockito.any(), Mockito.any());
-
+
Function funcObj = new Function(trans, ques);
Result<Void> result = funcObj.extendUserRole(trans, urData, false);
assertNull(result);
-
+
Mockito.doReturn(retVal).when(roleDAO).read(Mockito.any(), Mockito.anyString(), Mockito.anyString());
Mockito.doReturn(retValSuc).when(userRoleDAO).read(trans, urData);
result = funcObj.extendUserRole(trans, urData, true);
assertTrue(result.status == Status.ERR_RoleNotFound);
-
+
Mockito.doReturn(retVal).when(userRoleDAO).read(trans, urData);
result = funcObj.extendUserRole(trans, urData, true);
assertTrue(result.status == Status.ERR_UserRoleNotFound);
}
-
+
@SuppressWarnings("deprecation")
@Test
public void testGetUsersByRole() {
@@ -1547,7 +1547,7 @@ public class JU_Function {
urData.expires=new Date();
urDataAl.add(urData);
Result<List<UserRoleDAO.Data>> retVal = new Result<List<UserRoleDAO.Data>>(urDataAl,0,"test",NO_PARAM);
- Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
+ Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
Function funcObj = new Function(trans, ques);
Result<List<String>> result = funcObj.getUsersByRole(trans, "test", false);
@@ -1555,11 +1555,11 @@ public class JU_Function {
result = funcObj.getUsersByRole(trans, "test", true);
assertTrue(result.status == 0);
-
+
urData.expires=new Date(130,1,1);
result = funcObj.getUsersByRole(trans, "test", true);
assertTrue(result.status == 0);
-//
+//
}
@Test
public void testDelUserRole() {
@@ -1571,26 +1571,26 @@ public class JU_Function {
urData.expires=new Date();
urDataAl.add(urData);
Result<List<UserRoleDAO.Data>> retVal = new Result<List<UserRoleDAO.Data>>(urDataAl,0,"test",NO_PARAM);
- Mockito.doReturn(retVal).when(userRoleDAO).read(Mockito.any(), Mockito.any( UserRoleDAO.Data.class));
+ Mockito.doReturn(retVal).when(userRoleDAO).read(Mockito.any(), Mockito.any( UserRoleDAO.Data.class));
Function funcObj = new Function(trans, ques);
Result<Void> result = funcObj.delUserRole(trans, "test", "test", "test");
assertNull(result);
-
+
retVal = new Result<List<UserRoleDAO.Data>>(urDataAl,1,"test",NO_PARAM);
Mockito.doReturn(retVal).when(userRoleDAO).read(Mockito.any(), Mockito.any( UserRoleDAO.Data.class));
result = funcObj.delUserRole(trans, "test", "test", "test");
-// assertTrue(result.status ==1);
-//
+// assertTrue(result.status ==1);
+//
}
-
+
@Test
public void testCreateFuture() {
FutureDAO.Data data = new FutureDAO.Data();
data.memo = "test";
NsDAO.Data nsd = new NsDAO.Data();
nsd.name = "test";
-
+
List<UserRoleDAO.Data> urDataAl = new ArrayList<>();
UserRoleDAO.Data urData = new UserRoleDAO.Data();
urData.ns="test";
@@ -1600,7 +1600,7 @@ public class JU_Function {
urDataAl.add(urData);
Result<List<UserRoleDAO.Data>> retVal = new Result<List<UserRoleDAO.Data>>(urDataAl,0,"test",NO_PARAM);
Result<List<UserRoleDAO.Data>> retValFail = new Result<List<UserRoleDAO.Data>>(urDataAl,1,"test",NO_PARAM);
- Mockito.doReturn(retVal).when(userRoleDAO).read(Mockito.any(), Mockito.any( UserRoleDAO.Data.class));
+ Mockito.doReturn(retVal).when(userRoleDAO).read(Mockito.any(), Mockito.any( UserRoleDAO.Data.class));
Function funcObj = new Function(trans, ques);
Result<String> result = funcObj.createFuture(trans, data, "test", "test", nsd, FUTURE_OP.A);
@@ -1618,23 +1618,23 @@ public class JU_Function {
data.memo = "test";
Result<FutureDAO.Data> retValFuture = new Result<FutureDAO.Data>(futureData,0,"test",NO_PARAM);
Mockito.doReturn(retValFuture).when(futureDAO).create(Mockito.any(), Mockito.any( FutureDAO.Data.class), Mockito.anyString());
-
+
ApprovalDAO.Data approvalData = new ApprovalDAO.Data();
data.memo = "test";
Result<ApprovalDAO.Data> retValApproval = new Result<ApprovalDAO.Data>(approvalData,0,"test",NO_PARAM);
Mockito.doReturn(retValApproval).when(approvalDAO).create(Mockito.any(), Mockito.any( ApprovalDAO.Data.class));
-
- Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
+
+ Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
result = funcObj.createFuture(trans, data, "test", "test", nsd, FUTURE_OP.A);
assertTrue(result.status == 0);
-
+
result = funcObj.createFuture(trans, data, "test", "test", null, FUTURE_OP.A);
assertTrue(result.status == 20);
Mockito.doReturn(retValFail).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
result = funcObj.createFuture(trans, data, "test", "test", nsd, FUTURE_OP.A);
assertTrue(result.status == Result.ERR_NotFound);
-
+
Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
try {
Mockito.doReturn(null).when(org).getIdentity(trans, "test");
@@ -1644,7 +1644,7 @@ public class JU_Function {
}
result = funcObj.createFuture(trans, data, "test", "test", nsd, FUTURE_OP.A);
assertTrue(result.status == Result.ERR_NotFound);
-
+
try {
Mockito.doReturn(iden).when(org).getIdentity(trans, "test");
} catch (OrganizationException e) {
@@ -1653,7 +1653,7 @@ public class JU_Function {
}
result = funcObj.createFuture(trans, data, "test", "test", nsd, FUTURE_OP.C);
assertTrue(result.status == 0);
-
+
retValApproval = new Result<ApprovalDAO.Data>(null,1,"test",NO_PARAM);
Mockito.doReturn(retValApproval).when(approvalDAO).create(Mockito.any(), Mockito.any( ApprovalDAO.Data.class));
result = funcObj.createFuture(trans, data, "test", "test", nsd, FUTURE_OP.A);
@@ -1671,22 +1671,22 @@ public class JU_Function {
urDataAl.add(urData);
Result<List<UserRoleDAO.Data>> retVal = new Result<List<UserRoleDAO.Data>>(urDataAl,0,"test",NO_PARAM);
Result<List<UserRoleDAO.Data>> retValFail = new Result<List<UserRoleDAO.Data>>(null,1,"test",NO_PARAM);
- Mockito.doReturn(retVal).when(userRoleDAO).read(trans, objArr);
-
+ Mockito.doReturn(retVal).when(userRoleDAO).read(trans, objArr);
+
Function funcObj = new Function(trans, ques);
funcObj.urDBLookup.get(trans, objArr);
-
- Mockito.doReturn(retValFail).when(userRoleDAO).read(trans, objArr);
+
+ Mockito.doReturn(retValFail).when(userRoleDAO).read(trans, objArr);
funcObj.urDBLookup.get(trans, objArr);
}
-
+
@Test
public void testPerformFutureOp() {
FutureDAO.Data futureDataDaoObj = new FutureDAO.Data();
futureDataDaoObj.memo="test";
futureDataDaoObj.target = "test";
futureDataDaoObj.id = new UUID(10L,10L);
-
+
final List<ApprovalDAO.Data> apprs = new ArrayList<>();
ApprovalDAO.Data approvalObj = new ApprovalDAO.Data();
approvalObj.status = "approved";
@@ -1698,7 +1698,7 @@ public class JU_Function {
return apprs;
}
};
-
+
final UserRoleDAO.Data userObj = new UserRoleDAO.Data();
Lookup<UserRoleDAO.Data> lookupUserObj = new Lookup<UserRoleDAO.Data>() {
@Override
@@ -1706,61 +1706,61 @@ public class JU_Function {
return userObj;
}
};
-
+
FutureDAO.Data futureData = new FutureDAO.Data();
// data.memo = "test";
Result<FutureDAO.Data> retValFuture = new Result<FutureDAO.Data>(futureData,0,"test",NO_PARAM);
Mockito.doReturn(retValFuture).when(futureDAO).delete(Mockito.any(), Mockito.any( FutureDAO.Data.class), Mockito.anyBoolean());
-
+
// List<NsDAO.Data> dataAl = new ArrayList<NsDAO.Data>();
// NsDAO.Data dataObj = new NsDAO.Data();
// dataObj.type=1;
// dataAl.add(dataObj);
Result<List<UserRoleDAO.Data>> retVal = new Result<List<UserRoleDAO.Data>>(null,1,"test",NO_PARAM);
- Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
-//
+ Mockito.doReturn(retVal).when(userRoleDAO).readByRole(Mockito.any(), Mockito.anyString());
+//
// Result<NsDAO.Data> retVal2 = new Result<NsDAO.Data>(null,0,"test",NO_PARAM);
// Mockito.doReturn(retVal2).when(ques).mayUser(trans, null,retVal.value.get(0), Access.write);
-//
+//
Function funcObj = new Function(trans, ques);
Result<Function.OP_STATUS> result = funcObj.performFutureOp(trans, FUTURE_OP.A, futureDataDaoObj, lookupApprovalObj, lookupUserObj);
assertTrue(result.status == 0);
-
+
approvalObj.status = "approved";
approvalObj.type = "supervisor";
result = funcObj.performFutureOp(trans, FUTURE_OP.A, futureDataDaoObj, lookupApprovalObj, lookupUserObj);
assertTrue(result.status == 0);
-
+
approvalObj.status = "approved";
approvalObj.type = "";
result = funcObj.performFutureOp(trans, FUTURE_OP.A, futureDataDaoObj, lookupApprovalObj, lookupUserObj);
assertTrue(result.status == 0);
-
+
approvalObj.status = "pending";
approvalObj.type = "supervisor";
result = funcObj.performFutureOp(trans, FUTURE_OP.A, futureDataDaoObj, lookupApprovalObj, lookupUserObj);
assertTrue(result.status == 0);
-
+
approvalObj.status = "pending";
approvalObj.type = "owner";
result = funcObj.performFutureOp(trans, FUTURE_OP.A, futureDataDaoObj, lookupApprovalObj, lookupUserObj);
assertTrue(result.status == 0);
-
+
approvalObj.status = "pending";
approvalObj.type = "";
result = funcObj.performFutureOp(trans, FUTURE_OP.A, futureDataDaoObj, lookupApprovalObj, lookupUserObj);
assertTrue(result.status == 0);
-
+
approvalObj.status = "denied";
approvalObj.type = "";
result = funcObj.performFutureOp(trans, FUTURE_OP.A, futureDataDaoObj, lookupApprovalObj, lookupUserObj);
assertTrue(result.status == 0);
-
+
retValFuture = new Result<FutureDAO.Data>(futureData,1,"test",NO_PARAM);
Mockito.doReturn(retValFuture).when(futureDAO).delete(Mockito.any(), Mockito.any( FutureDAO.Data.class), Mockito.anyBoolean());
result = funcObj.performFutureOp(trans, FUTURE_OP.A, futureDataDaoObj, lookupApprovalObj, lookupUserObj);
System.out.println(result);
assertTrue(result.status == 0);
-//
+//
}
}
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/hl/JU_PermLookup.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/hl/JU_PermLookup.java
index 7e1abeba..f5d22ba2 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/hl/JU_PermLookup.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/hl/JU_PermLookup.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -51,17 +51,17 @@ import org.onap.aaf.cadi.CadiException;
import org.onap.aaf.misc.env.LogTarget;
-@RunWith(MockitoJUnitRunner.class)
+@RunWith(MockitoJUnitRunner.class)
public class JU_PermLookup {
-
-
+
+
@Mock
AuthzTrans trans;
-
+
@Mock
Question q;
-
+
@Mock
Access access;
@@ -70,40 +70,40 @@ public class JU_PermLookup {
@Mock
CachedUserRoleDAO userRoleDAO;
-
+
Function f;
-
+
@Before
public void setUp() throws Exception {
initMocks(this);
Mockito.doReturn(userRoleDAO).when(q).userRoleDAO();
Mockito.doReturn(roleDAO).when(q).roleDAO();
-
+
try {
Mockito.doReturn("0.0").when(access).getProperty("aaf_root_ns","org.osaaf.aaf");
Mockito.doReturn(new Properties()).when(access).getProperties();
Define.set(access);
-
+
when(trans.error()).thenReturn(new LogTarget() {
-
+
@Override
public void printf(String fmt, Object... vars) {}
-
+
@Override
public void log(Throwable e, Object... msgs) {
e.getMessage();
e.printStackTrace();
msgs.toString();
-
+
}
-
+
@Override
public void log(Object... msgs) {
}
-
+
@Override
public boolean isLoggable() {
-
+
return true;
}
});
@@ -113,70 +113,70 @@ public class JU_PermLookup {
}
f =new Function(trans, q);
}
-
-
+
+
// @Test
// public void testPerm() {
-//
+//
// PermLookup cassExecutorObj =PermLookup.get(trans, q,"");
-//
+//
//// System.out.println(cassExecutorObj);
//// assertFalse(retVal);
// }
-
+
@Test
public void testGetUserRole() {
@SuppressWarnings("unchecked")
Result<List<UserRoleDAO.Data>> retVal1 = Mockito.mock(Result.class);
retVal1.value = new ArrayList<UserRoleDAO.Data>();
UserRoleDAO.Data dataObj = Mockito.mock( UserRoleDAO.Data.class);
-
+
dataObj.expires = new Date();
-
+
retVal1.value.add(dataObj);
Mockito.doReturn(true).when(retVal1).isOKhasData();
Mockito.doReturn(retVal1).when(userRoleDAO).readByUser(trans,"");
PermLookup cassExecutorObj =PermLookup.get(trans, q,"");
Result<List<UserRoleDAO.Data>> userRoles = cassExecutorObj.getUserRoles();
-
+
//System.out.println(""+userRoles.status);
assertEquals(24,userRoles.status);
}
-
+
@Test
public void testGetUserRolesFirstIf() {
@SuppressWarnings("unchecked")
Result<List<UserRoleDAO.Data>> retVal1 = Mockito.mock(Result.class);
retVal1.value = new ArrayList<UserRoleDAO.Data>();
-
+
Mockito.doReturn(false).when(retVal1).isOKhasData();
Mockito.doReturn(retVal1).when(userRoleDAO).readByUser(trans,"");
PermLookup cassExecutorObj =PermLookup.get(trans, q,"");
Result<List<UserRoleDAO.Data>> userRoles = cassExecutorObj.getUserRoles();
-
+
// System.out.println("output is"+userRoles.status);
assertEquals(0,userRoles.status);
}
-
+
@Test
public void testGetUserRolesSecondIf() {
@SuppressWarnings("unchecked")
Result<List<UserRoleDAO.Data>> retVal1 = Mockito.mock(Result.class);
retVal1.value = new ArrayList<UserRoleDAO.Data>();
UserRoleDAO.Data dataObj = Mockito.mock( UserRoleDAO.Data.class);
-
+
Date dt = new Date();
- Calendar c = Calendar.getInstance();
- c.setTime(dt);
+ Calendar c = Calendar.getInstance();
+ c.setTime(dt);
c.add(Calendar.DATE, 1);
dataObj.expires = c.getTime();
-
+
retVal1.value.add(dataObj);
Mockito.doReturn(true).when(retVal1).isOKhasData();
Mockito.doReturn(retVal1).when(userRoleDAO).readByUser(trans,"");
PermLookup cassExecutorObj =PermLookup.get(trans, q,"");
Result<List<UserRoleDAO.Data>> userRoles = cassExecutorObj.getUserRoles();
-
+
//System.out.println(userRoles.status);
assertEquals("Success",userRoles.details);
Result<List<UserRoleDAO.Data>> userRoles1 = cassExecutorObj.getUserRoles();
@@ -184,38 +184,38 @@ public class JU_PermLookup {
//System.out.println(userRoles1.status);
assertEquals(0, userRoles1.status);
}
-
+
@Test
public void testGetRole() {
@SuppressWarnings("unchecked")
Result<List<UserRoleDAO.Data>> retVal1 = Mockito.mock(Result.class);
retVal1.value = new ArrayList<UserRoleDAO.Data>();
UserRoleDAO.Data dataObj = Mockito.mock( UserRoleDAO.Data.class);
-
+
dataObj.expires = new Date();
-
+
retVal1.value.add(dataObj);
Mockito.doReturn(false).when(retVal1).isOKhasData();
Mockito.doReturn(true).when(retVal1).isOK();
Mockito.doReturn(retVal1).when(userRoleDAO).readByUser(trans,"");
PermLookup cassExecutorObj =PermLookup.get(trans, q,"");
Result<List<RoleDAO.Data>> userRoles = cassExecutorObj.getRoles();
-
+
//System.out.println(""+userRoles.status);
assertEquals(4,userRoles.status);
}
-
+
@Test
public void testGetRoleFirstIf() {
@SuppressWarnings("unchecked")
Result<List<UserRoleDAO.Data>> retVal1 = Mockito.mock(Result.class);
retVal1.value = new ArrayList<UserRoleDAO.Data>();
UserRoleDAO.Data dataObj = Mockito.mock( UserRoleDAO.Data.class);
-
+
dataObj.expires = new Date();
dataObj.ns="";
dataObj.rname="";
-
+
retVal1.value.add(dataObj);
Mockito.doReturn(false).when(retVal1).isOKhasData();
Mockito.doReturn(false).when(retVal1).isOK();
@@ -223,22 +223,22 @@ public class JU_PermLookup {
Mockito.doReturn(retVal1).when(roleDAO).read(trans,"","");
PermLookup cassExecutorObj =PermLookup.get(trans, q,"");
Result<List<RoleDAO.Data>> userRoles = cassExecutorObj.getRoles();
-
+
// System.out.println(""+userRoles.status);
assertEquals(0,userRoles.status);
}
-
+
@Test
public void testGetRoleSecondIf() {
@SuppressWarnings("unchecked")
Result<List<UserRoleDAO.Data>> retVal1 = Mockito.mock(Result.class);
retVal1.value = new ArrayList<UserRoleDAO.Data>();
UserRoleDAO.Data dataObj = Mockito.mock( UserRoleDAO.Data.class);
-
+
dataObj.expires = new Date();
dataObj.ns="";
dataObj.rname="";
-
+
retVal1.value.add(dataObj);
Mockito.doReturn(false).when(retVal1).isOKhasData();
Mockito.doReturn(true).when(retVal1).isOK();
@@ -247,7 +247,7 @@ public class JU_PermLookup {
PermLookup cassExecutorObj =PermLookup.get(trans, q,"");
Result<List<RoleDAO.Data>> userRoles = cassExecutorObj.getRoles();
userRoles = cassExecutorObj.getRoles();
-
+
// System.out.println(""+userRoles.status);
assertEquals(0,userRoles.status);
}
@@ -262,7 +262,7 @@ public class JU_PermLookup {
PermLookup cassExecutorObj =PermLookup.get(trans, q,"");
Result<Set<String>> userRoles = cassExecutorObj.getPermNames();
userRoles = cassExecutorObj.getPermNames();
-
+
//System.out.println(""+userRoles.status);
assertEquals(0,userRoles.status);
}
@@ -272,19 +272,19 @@ public class JU_PermLookup {
Result<List<UserRoleDAO.Data>> retVal1 = Mockito.mock(Result.class);
retVal1.value = new ArrayList<UserRoleDAO.Data>();
UserRoleDAO.Data dataObj = Mockito.mock( UserRoleDAO.Data.class);
-
+
dataObj.expires = new Date();
-
+
retVal1.value.add(dataObj);
Mockito.doReturn(false).when(retVal1).isOKhasData();
Mockito.doReturn(true).when(retVal1).isOK();
Mockito.doReturn(retVal1).when(userRoleDAO).readByUser(trans,"");
PermLookup cassExecutorObj =PermLookup.get(trans, q,"");
Result<Set<String>> userRoles = cassExecutorObj.getPermNames();
-
+
//System.out.println(""+userRoles.status);
assertEquals(4,userRoles.status);
- }
+ }
@SuppressWarnings("unchecked")
@@ -292,31 +292,31 @@ public class JU_PermLookup {
public void testGetPerm() {
Result<List<UserRoleDAO.Data>> retVal1 = Mockito.mock(Result.class);
Result<List<RoleDAO.Data>> retVal2 = Mockito.mock(Result.class);
-
+
retVal1.value = new ArrayList<UserRoleDAO.Data>();
retVal2.value = new ArrayList<RoleDAO.Data>();
UserRoleDAO.Data dataObj = Mockito.mock( UserRoleDAO.Data.class);
-
+
Date dt = new Date();
- Calendar c = Calendar.getInstance();
- c.setTime(dt);
+ Calendar c = Calendar.getInstance();
+ c.setTime(dt);
c.add(Calendar.DATE, 1);
dataObj.expires = c.getTime();
dataObj.ns = "";
dataObj.rname="";
-
+
RoleDAO.Data dataObj1 = Mockito.mock( RoleDAO.Data.class);
Set<String> permSet = new HashSet<String>();
permSet.add("test");
Mockito.doReturn(permSet).when(dataObj1).perms(false);
-
+
dt = new Date();
- c = Calendar.getInstance();
- c.setTime(dt);
+ c = Calendar.getInstance();
+ c.setTime(dt);
c.add(Calendar.DATE, 1);
dataObj1.ns = "test";
dataObj1.perms = permSet;
-
+
retVal1.value.add(dataObj);
retVal2.value.add(dataObj1);
Mockito.doReturn(true).when(retVal1).isOKhasData();
@@ -325,47 +325,47 @@ public class JU_PermLookup {
Mockito.doReturn(retVal1).when(userRoleDAO).readByUser(trans,"");
Mockito.doReturn(retVal2).when(roleDAO).read(trans,"","");
-
+
PermLookup cassExecutorObj =PermLookup.get(trans, q,"");
-//
+//
// Mockito.doReturn(retVal2).when(cassExecutorObj).getPermNames();
Result<List<Data>> userRoles = cassExecutorObj.getPerms(true);
// userRoles = cassExecutorObj.getPerms(false);
-
+
// System.out.println(""+userRoles.status);
assertEquals(0,userRoles.status);
}
-
+
@SuppressWarnings("unchecked")
@Test
public void testGetPermFalse() {
Result<List<UserRoleDAO.Data>> retVal1 = Mockito.mock(Result.class);
Result<List<RoleDAO.Data>> retVal2 = Mockito.mock(Result.class);
-
+
retVal1.value = new ArrayList<UserRoleDAO.Data>();
retVal2.value = new ArrayList<RoleDAO.Data>();
UserRoleDAO.Data dataObj = Mockito.mock( UserRoleDAO.Data.class);
-
+
Date dt = new Date();
- Calendar c = Calendar.getInstance();
- c.setTime(dt);
+ Calendar c = Calendar.getInstance();
+ c.setTime(dt);
c.add(Calendar.DATE, 1);
dataObj.expires = c.getTime();
dataObj.ns = "";
dataObj.rname="";
-
+
RoleDAO.Data dataObj1 = Mockito.mock( RoleDAO.Data.class);
Set<String> permSet = new HashSet<String>();
permSet.add("test");
Mockito.doReturn(permSet).when(dataObj1).perms(false);
-
+
dt = new Date();
- c = Calendar.getInstance();
- c.setTime(dt);
+ c = Calendar.getInstance();
+ c.setTime(dt);
c.add(Calendar.DATE, 1);
dataObj1.ns = "test";
dataObj1.perms = permSet;
-
+
retVal1.value.add(dataObj);
retVal2.value.add(dataObj1);
Mockito.doReturn(true).when(retVal1).isOKhasData();
@@ -374,15 +374,15 @@ public class JU_PermLookup {
Mockito.doReturn(retVal1).when(userRoleDAO).readByUser(trans,"");
Mockito.doReturn(retVal2).when(roleDAO).read(trans,"","");
-
+
PermLookup cassExecutorObj =PermLookup.get(trans, q,"");
-//
+//
// Mockito.doReturn(retVal2).when(cassExecutorObj).getPermNames();
Result<List<Data>> userRoles = cassExecutorObj.getPerms(false);
userRoles = cassExecutorObj.getPerms(false);
-
+
// System.out.println(""+userRoles.status);
assertEquals(0,userRoles.status);
}
-
+
} \ No newline at end of file
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFLocator.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFLocator.java
index 5a7d4959..05623127 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFLocator.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFLocator.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -48,26 +48,26 @@ import org.onap.aaf.cadi.config.Config;
import junit.framework.Assert;
-@RunWith(MockitoJUnitRunner.class)
+@RunWith(MockitoJUnitRunner.class)
public class JU_DirectAAFLocator {
@Mock
LocateDAO ldao;
-
+
@Mock
AuthzEnv env;
-
+
@Mock
AuthzTrans trans;
-
+
@Mock
PropAccess access;
-
+
@Before
public void setUp() throws Exception {
initMocks(this);
}
-
+
@Test
public void testConstructorVersionExcpetion() {
Mockito.doReturn(access).when(env).access();
@@ -97,7 +97,7 @@ public class JU_DirectAAFLocator {
assertEquals("Invalid Version String: 20.20.20.test", e.getMessage());
}
}
-
+
@Test
public void testConstructorExcpetion() {
Mockito.doReturn(access).when(env).access();
@@ -112,7 +112,7 @@ public class JU_DirectAAFLocator {
// System.out.println(e.getMessage());
}
}
-
+
// NOTE: These mocks to not well represent the DirectAAFLocator Class.
@Test
public void testConstructorUriExcpetion() {
@@ -133,7 +133,7 @@ public class JU_DirectAAFLocator {
@Test
public void testRefresh() {
-
+
DirectAAFLocator aafLocatorObj=null;
PropAccess access = Mockito.mock(PropAccess.class);
Mockito.doReturn(access).when(env).access();
@@ -150,7 +150,7 @@ public class JU_DirectAAFLocator {
e.printStackTrace();
}
Result<List<Data>> retVal1 = new Result<List<Data>>(null,0,"",new Object[0]);
-
+
Data data= new Data();
data.major=30;
data.minor=30;
@@ -158,16 +158,16 @@ public class JU_DirectAAFLocator {
data.pkg=30;
retVal1.value = new ArrayList<Data>();
retVal1.value.add(data);
-
+
Mockito.doReturn(retVal1).when(ldao).readByName(trans,"test");
boolean retVal = aafLocatorObj.refresh();
// System.out.println(retVal);
assertTrue(retVal);
- }
-
+ }
+
@Test
public void testRefreshNOK() {
-
+
DirectAAFLocator aafLocatorObj=null;
PropAccess access = Mockito.mock(PropAccess.class);
Mockito.doReturn(access).when(env).access();
@@ -184,11 +184,11 @@ public class JU_DirectAAFLocator {
e.printStackTrace();
}
Result<List<Data>> retVal1 = new Result<List<Data>>(null,1,"",new String[0]);
-
+
Mockito.doReturn(retVal1).when(ldao).readByName(trans,"test");
boolean retVal = aafLocatorObj.refresh();
// System.out.println(retVal);
assertFalse(retVal);
- }
-
+ }
+
} \ No newline at end of file
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFLur.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFLur.java
index 0ed6e60c..dbd517a0 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFLur.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFLur.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -51,34 +51,34 @@ import org.onap.aaf.cadi.lur.LocalPermission;
import org.onap.aaf.misc.env.LogTarget;
import org.onap.aaf.misc.env.Trans;
-@RunWith(MockitoJUnitRunner.class)
+@RunWith(MockitoJUnitRunner.class)
public class JU_DirectAAFLur {
@Mock
AuthzEnv env;
-
+
@Mock
Question question;
-
+
@Mock
Principal bait;
-
+
@Mock
Permission pond;
-
+
@Mock
AuthzTrans trans;
-
+
@Before
public void setUp() throws Exception {
initMocks(this);
Mockito.when(env.newTransNoAvg()).thenReturn(trans);
Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).error();
}
-
+
public void testFish() {
DirectAAFLur aafLurObj = new DirectAAFLur(env, question);
-
+
List<PermDAO.Data> rsVal = new ArrayList<PermDAO.Data>();
Result<List<Data>> rs = new Result<List<Data>>(rsVal,0,"test",new Object[0]);
Mockito.when(question.getPermsByUser(env.newTransNoAvg(), bait.getName(), false)).thenReturn(rs);
@@ -88,7 +88,7 @@ public class JU_DirectAAFLur {
@Test
public void testFishSecondMtd() {
DirectAAFLur aafLurObj = new DirectAAFLur(env, question);
-
+
List<PermDAO.Data> rsVal = new ArrayList<PermDAO.Data>();
PermDAO.Data pd = new PermDAO.Data();
pd.ns = "ns";
@@ -101,7 +101,7 @@ public class JU_DirectAAFLur {
pd.instance = "instance";
pd.action = null;
rsVal.add(pd);
-
+
pd = new PermDAO.Data();
pd.ns = "ns";
pd.type = "name";
@@ -115,25 +115,25 @@ public class JU_DirectAAFLur {
pd.ns = "ns";
pd.type = "name1";
rsVal.add(pd);
-
+
pd = new PermDAO.Data();
pd.ns = "ns";
pd.type = "name";
pd.instance = "instance";
pd.action = "action";
rsVal.add(pd);
-
+
pond = new DirectAAFLur.PermPermission("ns", "name", "instance", "action");
-
+
Result<List<Data>> rs = new Result<List<Data>>(rsVal,0,"test",new Object[0]);
Mockito.when(question.getPermsByUser(env.newTransNoAvg(), bait.getName(), false)).thenReturn(rs);
aafLurObj.fish(bait, pond);
-
+
pond = new AAFPermission("ns", "name", "instance", "action");
-
+
Mockito.when(question.getPermsByUser(env.newTransNoAvg(), bait.getName(), false)).thenReturn(rs);
aafLurObj.fish(bait, pond);
-
+
rs = new Result<List<Data>>(rsVal,1,"test",new Object[0]);
Mockito.when(question.getPermsByUser(env.newTransNoAvg(), bait.getName(), false)).thenReturn(rs);
aafLurObj.fish(bait, pond);
@@ -144,76 +144,76 @@ public class JU_DirectAAFLur {
Mockito.when(question.getPermsByUser(env.newTransNoAvg(), bait.getName(), false)).thenReturn(rs);
aafLurObj.fish(bait, pond);
}
-
+
@Test
public void testFishAll() {
Mockito.doReturn(Mockito.mock(LogTarget.class)).when(env).error();
DirectAAFLur aafLurObj = new DirectAAFLur(env, question);
-
+
List<PermDAO.Data> rsVal = new ArrayList<PermDAO.Data>();
PermDAO.Data pd = new PermDAO.Data();
pd.ns = "ns";
pd.type = "name";
pd.instance = null;
rsVal.add(pd);
-
+
pond = new DirectAAFLur.PermPermission("ns", "name", "instance", "action");
List<Permission> permissions = new ArrayList<>();
permissions.add(pond);
-
+
Result<List<Data>> rs = new Result<List<Data>>(rsVal,0,"test",new Object[0]);
Mockito.when(question.getPermsByUser(env.newTrans(), bait.getName(), false)).thenReturn(rs);
aafLurObj.fishAll(bait, permissions);
assertTrue(permissions.size() == 2);
-
+
rs = new Result<List<Data>>(rsVal,1,"test",new Object[0]);
Mockito.when(question.getPermsByUser(env.newTrans(), bait.getName(), false)).thenReturn(rs);
aafLurObj.fishAll(bait, permissions);
}
-
+
@Test
public void testDestroy() {
DirectAAFLur aafLurObj = new DirectAAFLur(env, question);
aafLurObj.destroy();
}
-
+
@Test
public void testHandlesExclusively() {
DirectAAFLur aafLurObj = new DirectAAFLur(env, question);
pond = new DirectAAFLur.PermPermission("ns", "name", "instance", "action");
assertFalse(aafLurObj.handlesExclusively(pond));
}
-
+
@Test
public void testToString() {
DirectAAFLur aafLurObj = new DirectAAFLur(env, question);
assertTrue(aafLurObj.toString().contains("DirectAAFLur is enabled"));
}
-
+
@Test
public void testHandles() {
DirectAAFLur aafLurObj = new DirectAAFLur(env, question);
assertTrue(aafLurObj.handles(null));
}
-
+
@Test
public void testCreatePerm() {
DirectAAFLur aafLurObj = new DirectAAFLur(env, question);
Permission retVal = aafLurObj.createPerm("test");
assertTrue(retVal instanceof LocalPermission);
-
+
NsSplit nss = new NsSplit("test", "test");
Result<NsSplit> rs = new Result<NsSplit>(nss,0,"test",new Object[0]);
Mockito.when(question.deriveNsSplit(NullTrans.singleton() , "test")).thenReturn(rs);
retVal = aafLurObj.createPerm("test|1|2");
assertTrue(retVal instanceof PermPermission);
-
+
rs = new Result<NsSplit>(null,1,"test",new Object[0]);
Mockito.when(question.deriveNsSplit(NullTrans.singleton() , "test")).thenReturn(rs);
retVal = aafLurObj.createPerm("test|1|2");
assertTrue(retVal instanceof LocalPermission);
}
-
+
@Test
public void testClear() {
AuthzTransImpl trans = Mockito.mock(AuthzTransImpl.class);
@@ -223,7 +223,7 @@ public class JU_DirectAAFLur {
Mockito.when(trans.auditTrail(0, sb)).thenReturn(Mockito.mock(Trans.Metric.class));
aafLurObj.clear(bait, sb);
}
-
+
@Test
public void testPermPermission() {
AuthzTransImpl trans = Mockito.mock(AuthzTransImpl.class);
@@ -231,12 +231,12 @@ public class JU_DirectAAFLur {
Result<NsSplit> rs = new Result<NsSplit>(nss,0,"test",new Object[0]);
Mockito.when(question.deriveNsSplit(trans , "test")).thenReturn(rs);
PermPermission pp = new PermPermission(trans, question, "test|test|test|test");
-
+
assertTrue("test".equalsIgnoreCase(pp.getKey()));
assertTrue("AAFLUR".equalsIgnoreCase(pp.permType()));
-
+
assertFalse(pp.match(null));
-
+
pond = new AAFPermission("test.test", "test", "test", "test");
assertTrue(pp.match(pond));
}
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFUserPass.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFUserPass.java
index 241d407b..03e3e932 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFUserPass.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectAAFUserPass.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -44,76 +44,76 @@ import org.onap.aaf.auth.layer.Result;
import org.onap.aaf.misc.env.LogTarget;
-@RunWith(MockitoJUnitRunner.class)
+@RunWith(MockitoJUnitRunner.class)
public class JU_DirectAAFUserPass {
@Mock
Question question;
-
+
@Mock
AuthzEnv env;
-
+
@Mock
AuthzTrans trans;
-
+
@Mock
HttpServletRequest request;
-
-
+
+
@Before
public void setUp() throws Exception {
initMocks(this);
when(env.warn()).thenReturn(new LogTarget() {
-
+
@Override
public void printf(String fmt, Object... vars) {}
-
+
@Override
public void log(Throwable e, Object... msgs) {
e.getMessage();
e.printStackTrace();
msgs.toString();
-
+
}
-
+
@Override
public void log(Object... msgs) {
}
-
+
@Override
public boolean isLoggable() {
-
+
return true;
}
});
when(env.error()).thenReturn(new LogTarget() {
-
+
@Override
public void printf(String fmt, Object... vars) {}
-
+
@Override
public void log(Throwable e, Object... msgs) {
e.getMessage();
e.printStackTrace();
msgs.toString();
-
+
}
-
+
@Override
public void log(Object... msgs) {
}
-
+
@Override
public boolean isLoggable() {
-
+
return true;
}
});
}
-
+
@Test
public void testUserPass() {
-
+
DirectAAFUserPass aafLocatorObj=null;
aafLocatorObj = new DirectAAFUserPass(env, question);
Result<Date> retVal1 = new Result<Date>(null,0,"",new String[0]);
@@ -124,13 +124,13 @@ public class JU_DirectAAFUserPass {
e.printStackTrace();
}
boolean retVal = aafLocatorObj.validate(null, null, null, null);
-
+
assertFalse(retVal);
- }
-
+ }
+
@Test
public void testUserPassStateisRequest() {
-
+
DirectAAFUserPass aafLocatorObj=null;
aafLocatorObj = new DirectAAFUserPass(env, question);
Result<Date> retVal1 = new Result<Date>(null,1,"",new String[0]);
@@ -141,14 +141,14 @@ public class JU_DirectAAFUserPass {
e.printStackTrace();
}
boolean retVal = aafLocatorObj.validate(null, null, null, request);
-
+
// System.out.println(retVal);
assertFalse(retVal);
}
-
+
@Test
public void testUserPassStateNotNull() {
-
+
DirectAAFUserPass aafLocatorObj=null;
aafLocatorObj = new DirectAAFUserPass(env, question);
Result<Date> retVal1 = new Result<Date>(null,1,"",new String[0]);
@@ -159,14 +159,14 @@ public class JU_DirectAAFUserPass {
e.printStackTrace();
}
boolean retVal = aafLocatorObj.validate(null, null, null, "test");
-
+
// System.out.println(retVal);
assertFalse(retVal);
}
-
+
@Test
public void testUserPassTransChk() {
-
+
DirectAAFUserPass aafLocatorObj=null;
aafLocatorObj = new DirectAAFUserPass(env, question);
Result<Date> retVal1 = new Result<Date>(null,1,"",new String[0]);
@@ -177,14 +177,14 @@ public class JU_DirectAAFUserPass {
e.printStackTrace();
}
boolean retVal = aafLocatorObj.validate(null, null, null, trans);
-
+
// System.out.println(retVal);
assertFalse(retVal);
}
-
+
@Test
public void testUserPassTransIpNotNull() {
-
+
DirectAAFUserPass aafLocatorObj=null;
aafLocatorObj = new DirectAAFUserPass(env, question);
Result<Date> retVal1 = new Result<Date>(null,1,"",new String[0]);
@@ -196,14 +196,14 @@ public class JU_DirectAAFUserPass {
e.printStackTrace();
}
boolean retVal = aafLocatorObj.validate(null, null, null, trans);
-
+
// System.out.println(retVal);
assertFalse(retVal);
}
-
+
@Test
public void testUserExceptionChk() {
-
+
DirectAAFUserPass aafLocatorObj=null;
aafLocatorObj = new DirectAAFUserPass(env, question);
Result<Date> retVal1 = new Result<Date>(null,1,"",new String[0]);
@@ -215,9 +215,9 @@ public class JU_DirectAAFUserPass {
// e.printStackTrace();
}
boolean retVal = aafLocatorObj.validate(null, null, null, trans);
-
+
// System.out.println(retVal);
assertFalse(retVal);
}
-
+
} \ No newline at end of file
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectCertIdentity.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectCertIdentity.java
index 81195e5d..d59e615c 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectCertIdentity.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectCertIdentity.java
@@ -7,9 +7,9 @@
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
- * *
+ * *
* * http://www.apache.org/licenses/LICENSE-2.0
- * *
+ * *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -66,17 +66,17 @@ public class JU_DirectCertIdentity {
try {
Principal p = directCertIdentity.identity(req, cert, _certBytes);
assertEquals(((p) == null), true);
-
+
cert = Mockito.mock(X509Certificate.class);
Mockito.when(cert.getEncoded()).thenReturn(new byte[128]);
-
+
Result<List<CertDAO.Data>> rs = new Result<List<CertDAO.Data>>(null, 1, "test", new Object[0]);
-
+
CachedCertDAO cacheDao = Mockito.mock(CachedCertDAO.class);
Mockito.when(cacheDao.read(Mockito.any(AuthzTrans.class),Mockito.any(Object[].class))).thenReturn(rs);
DirectCertIdentity.set(cacheDao);
p = directCertIdentity.identity(req, cert, _certBytes);
-
+
_certBytes = new byte[128];
List<CertDAO.Data> dataAL = new ArrayList<>();
CertDAO.Data data = new CertDAO.Data();
@@ -86,7 +86,7 @@ public class JU_DirectCertIdentity {
DirectCertIdentity.set(cacheDao);
p = directCertIdentity.identity(req, cert, _certBytes);
assertTrue(p.toString().contains("X509 Authentication for null"));
-
+
cert = null;
directCertIdentity.identity(req, cert, _certBytes);
} catch (CertificateException e) {
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectLocatorCreator.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectLocatorCreator.java
index 7ac4ed1b..d745b145 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectLocatorCreator.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectLocatorCreator.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -35,23 +35,23 @@ import org.onap.aaf.cadi.LocatorException;
import org.onap.aaf.cadi.PropAccess;
import org.onap.aaf.cadi.config.Config;
-@RunWith(MockitoJUnitRunner.class)
+@RunWith(MockitoJUnitRunner.class)
public class JU_DirectLocatorCreator {
@Mock
AuthzEnv env;
-
+
@Mock
LocateDAO locateDAO;
-
+
@Mock
PropAccess access;
-
+
@Before
public void setUp() throws Exception {
initMocks(this);
}
-
+
@Test
public void testCreate() {
Mockito.doReturn(access).when(env).access();
diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectRegistrar.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectRegistrar.java
index cf1bd9d4..833b8970 100644
--- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectRegistrar.java
+++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/direct/test/JU_DirectRegistrar.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -74,12 +74,12 @@ public class JU_DirectRegistrar {
Mockito.doReturn(rs).when(ldao).update(Mockito.any(), Mockito.any());
registrarObj = new DirectRegistrar(access, ldao, 9080);
-
+
org.onap.aaf.auth.layer.Result<Void> retVal1 = new Result<Void>(null, 0, "test", new Object[0]);
Mockito.doReturn(trans).when(env).newTransNoAvg();
// Mockito.doReturn(retVal1).when(ldao).update(trans,locate);
registrarObj.update(env);
-
+
rs = new org.onap.aaf.auth.layer.Result<Void>(null, 1, "test", new Object[0]);
Mockito.doReturn(rs).when(ldao).update(Mockito.any(), Mockito.any());
registrarObj = new DirectRegistrar(access, ldao, 9080);
@@ -100,7 +100,7 @@ public class JU_DirectRegistrar {
Mockito.doReturn("20").when(access).getProperty(Config.AAF_LOCATOR_CONTAINER, "");
Mockito.doReturn("20,test,test").when(access).getProperty(Config.AAF_LOCATOR_ENTRIES, "");
registrarObj = new DirectRegistrar(access, ldao, 9080);
-
+
org.onap.aaf.auth.layer.Result<Void> rs = new org.onap.aaf.auth.layer.Result<Void>(null, 1, "test", new Object[0]);
Mockito.doReturn(rs).when(ldao).delete(Mockito.any(), Mockito.any(), Mockito.anyBoolean());
} catch (CadiException e) {