Skip to content

Package: NoDatabaseManager

NoDatabaseManager

nameinstructionbranchcomplexitylinemethod
NoDatabaseManager()
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
clearTables()
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
connect()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
disconnect()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
getClassFacade()
M: 0 C: 11
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
getInstance()
M: 0 C: 8
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
getObjectFacade()
M: 4 C: 17
81%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 1 C: 4
80%
M: 0 C: 1
100%
isConnected()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
resetDatabase()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
setConnectionConstantsFromFile(PropertiesReader)
M: 0 C: 1
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: package de.fhdw.wtf.persistence.facade;
2:
3: import java.io.IOException;
4:
5: import de.fhdw.wtf.persistence.exception.ClassFacadeUninitializedException;
6: import de.fhdw.wtf.persistence.exception.PersistenceException;
7: import de.fhdw.wtf.persistence.utils.PropertiesReader;
8:
9: /**
10: * Manages actions on simulated database (called No-Database).
11: */
12: public final class NoDatabaseManager extends DatabaseManager {
13:         
14:         /**
15:          * The No Database Manager is a singleton, therefore one single instance is stored in this static field.
16:          */
17:         private static NoDatabaseManager instance;
18:         
19:         /**
20:          * The class facade.
21:          */
22:         private ClassFacade classFacade;
23:         
24:         /**
25:          * The object facade.
26:          */
27:         private ObjectFacade objectFacade;
28:         
29:         /**
30:          * It stores the information if the NoDatabase is connected or not to simulate a database connection. We need this
31:          * to use "connect()", "disconnect()" and "isConnected()" correctly.
32:          */
33:         private boolean connected = false;
34:         
35:         @Override
36:         public void setConnectionConstantsFromFile(final PropertiesReader reader) throws IOException {
37:                 // It is empty because we do not need to read some configurations but we have to implement this method to
38:                 // simulate a database
39:         }
40:         
41:         @Override
42:         public void connect() throws PersistenceException {
43:                 this.connected = true;
44:         }
45:         
46:         @Override
47:         public ClassFacade getClassFacade() {
48:•                if (this.classFacade == null) {
49:                         this.classFacade = new NoDatabaseClassFacadeImplementation();
50:                 }
51:                 return this.classFacade;
52:         }
53:         
54:         @Override
55:         public ObjectFacade getObjectFacade() throws ClassFacadeUninitializedException {
56:•                if (!this.getClassFacade().hasBeenInitialized()) {
57:                         throw new ClassFacadeUninitializedException();
58:                 }
59:•                if (this.objectFacade == null) {
60:                         this.objectFacade = new NoDatabaseObjectFacadeImplementation(this.classFacade);
61:                 }
62:                 return this.objectFacade;
63:         }
64:         
65:         @Override
66:         public void disconnect() throws PersistenceException {
67:                 this.connected = false;
68:         }
69:         
70:         @Override
71:         public boolean isConnected() {
72:                 return this.connected;
73:         }
74:         
75:         @Override
76:         public void resetDatabase() throws PersistenceException, IOException {
77:                 this.clearTables();
78:         }
79:         
80:         @Override
81:         public void clearTables() throws PersistenceException {
82:                 this.getClassFacade().clear();
83:                 this.getObjectFacade().clear();
84:         }
85:         
86:         /**
87:          * Provides the singleton instance of the No Database Manager.
88:          *
89:          * @return The No Database manager.
90:          */
91:         public static synchronized NoDatabaseManager getInstance() {
92:•                if (instance == null) {
93:                         instance = new NoDatabaseManager();
94:                 }
95:                 return instance;
96:         }
97:         
98: }