Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
aab9ba0a
Commit
aab9ba0a
authored
17 years ago
by
ribeaudc
Browse files
Options
Downloads
Patches
Plain Diff
change:
- finalyzing 'ChannelListTest' SVN: 2379
parent
8279643e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bds/source/java/ch/systemsx/cisd/bds/hcs/ChannelList.java
+15
-6
15 additions, 6 deletions
bds/source/java/ch/systemsx/cisd/bds/hcs/ChannelList.java
bds/sourceTest/java/ch/systemsx/cisd/bds/hcs/ChannelListTest.java
+40
-1
40 additions, 1 deletion
...ceTest/java/ch/systemsx/cisd/bds/hcs/ChannelListTest.java
with
55 additions
and
7 deletions
bds/source/java/ch/systemsx/cisd/bds/hcs/ChannelList.java
+
15
−
6
View file @
aab9ba0a
...
...
@@ -17,8 +17,8 @@
package
ch.systemsx.cisd.bds.hcs
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.List
;
import
ch.systemsx.cisd.bds.DataStructureException
;
...
...
@@ -31,7 +31,7 @@ import ch.systemsx.cisd.bds.storage.INode;
*
* @author Christian Ribeaud
*/
public
final
class
ChannelList
implements
IStorable
public
final
class
ChannelList
implements
IStorable
,
Iterable
<
Channel
>
{
static
final
String
NUMBER_OF_CHANNELS
=
"number_of_channels"
;
...
...
@@ -66,10 +66,10 @@ public final class ChannelList implements IStorable
return
new
ChannelList
(
channels
);
}
/** Returns
an unmodifiable list of <code>Channel</code>
. */
public
final
List
<
Channel
>
getChannel
s
()
/** Returns
the number of channels
. */
public
final
int
getChannel
Count
()
{
return
Collections
.
unmodifiableList
(
channels
);
return
channels
.
size
(
);
}
//
...
...
@@ -78,10 +78,19 @@ public final class ChannelList implements IStorable
public
final
void
saveTo
(
final
IDirectory
directory
)
{
directory
.
addKeyValuePair
(
NUMBER_OF_CHANNELS
,
c
hannel
s
.
size
()
+
""
);
directory
.
addKeyValuePair
(
NUMBER_OF_CHANNELS
,
getC
hannel
Count
()
+
""
);
for
(
Channel
channel
:
channels
)
{
channel
.
saveTo
(
directory
);
}
}
//
// Iterable
//
public
final
Iterator
<
Channel
>
iterator
()
{
return
channels
.
iterator
();
}
}
This diff is collapsed.
Click to expand it.
bds/sourceTest/java/ch/systemsx/cisd/bds/hcs/ChannelListTest.java
+
40
−
1
View file @
aab9ba0a
...
...
@@ -16,7 +16,9 @@
package
ch.systemsx.cisd.bds.hcs
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.List
;
import
org.testng.annotations.Test
;
...
...
@@ -43,6 +45,20 @@ public final class ChannelListTest extends AbstractFileSystemTestCase
return
new
ChannelList
(
list
);
}
private
final
static
void
checkFile
(
final
File
file
)
{
assertTrue
(
file
.
getName
().
equals
(
ChannelList
.
NUMBER_OF_CHANNELS
)
||
file
.
getName
().
startsWith
(
Channel
.
CHANNEL
));
}
private
final
static
void
checkChannelFile
(
final
File
channelFile
)
{
assertNotNull
(
channelFile
);
assertTrue
(
channelFile
.
isDirectory
());
final
File
[]
files
=
channelFile
.
listFiles
();
assertEquals
(
1
,
files
.
length
);
assertEquals
(
files
[
0
].
getName
(),
Channel
.
WAVELENGTH
);
}
@Test
public
final
void
testConstructor
()
{
...
...
@@ -78,6 +94,29 @@ public final class ChannelListTest extends AbstractFileSystemTestCase
final
ChannelList
channelList
=
createChannelList
();
final
IDirectory
dir
=
NodeFactory
.
createDirectoryNode
(
workingDirectory
);
channelList
.
saveTo
(
dir
);
final
File
[]
files
=
workingDirectory
.
listFiles
();
assertEquals
(
3
,
files
.
length
);
for
(
File
file
:
files
)
{
checkFile
(
file
);
if
(
file
.
getName
().
startsWith
(
Channel
.
CHANNEL
))
{
checkChannelFile
(
file
);
}
}
}
@Test
(
dependsOnMethods
=
"testSaveTo"
)
public
final
void
testLoadFrom
()
{
testSaveTo
();
final
IDirectory
dir
=
NodeFactory
.
createDirectoryNode
(
workingDirectory
);
final
ChannelList
channelList
=
ChannelList
.
loadFrom
(
dir
);
assertEquals
(
2
,
channelList
.
getChannelCount
());
final
Iterator
<
Channel
>
iterator
=
channelList
.
iterator
();
Channel
channel
=
iterator
.
next
();
assertEquals
(
123
,
channel
.
getWavelength
());
channel
=
iterator
.
next
();
assertEquals
(
456
,
channel
.
getWavelength
());
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment