From a7147d16c31d9028c6b5dc557264433de0f11c91 Mon Sep 17 00:00:00 2001 From: Jan Srnicek Date: Fri, 23 Sep 2016 16:39:09 +0200 Subject: HONEYCOMB-145 - Utility Class Refactoring problematic mockito-all changed to mockito-core( https://github.com/mockito/mockito/issues/324) Translate Utils Splitted to multiple Trait Interfaces Ipv4Translator - Logic for translation of ipv4-based data Ipv6Translator - Logic for translation of ipv6-based data MacTranslator - Logic for translation of mac-based data AddressTranslator - Aggregation trait for Ipv4/Ipv6/Mac JvppReplyConsumer - Logic for extracting replies from jvpp calls ByteDataTranslator - any byte-based conversions Plus some existing utility classes changed to traits Change-Id: I342b625954223966802e65dca0fabf8456c89345 Signed-off-by: Jan Srnicek --- .../v3po/vppclassifier/ClassifyTableWriter.java | 26 ++++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableWriter.java') diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableWriter.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableWriter.java index 3dc3cf7d1..6f4959c23 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableWriter.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableWriter.java @@ -19,11 +19,11 @@ package io.fd.honeycomb.translate.v3po.vppclassifier; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; -import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.booleanToByte; import io.fd.honeycomb.translate.MappingContext; import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer; -import io.fd.honeycomb.translate.v3po.util.TranslateUtils; +import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator; +import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; import java.util.concurrent.CompletionStage; @@ -44,7 +44,7 @@ import org.slf4j.LoggerFactory; * VPP.
Equivalent to invoking {@code vppctl classify table} command. */ public class ClassifyTableWriter extends VppNodeWriter - implements ListWriterCustomizer { + implements ListWriterCustomizer, ByteDataTranslator, JvppReplyConsumer { private static final Logger LOG = LoggerFactory.getLogger(ClassifyTableWriter.class); private final VppClassifierContextManager classifyTableContext; @@ -58,14 +58,16 @@ public class ClassifyTableWriter extends VppNodeWriter @Override public void writeCurrentAttributes(@Nonnull final InstanceIdentifier id, @Nonnull final ClassifyTable dataAfter, @Nonnull final WriteContext writeContext) - throws WriteFailedException { + throws WriteFailedException { LOG.debug("Creating classify table: iid={} dataAfter={}", id, dataAfter); try { final int newTableIndex = - classifyAddDelTable(true, id, dataAfter, ~0 /* value not present */, writeContext.getMappingContext()); + classifyAddDelTable(true, id, dataAfter, ~0 /* value not present */, + writeContext.getMappingContext()); // Add classify table name <-> vpp index mapping to the naming context: - classifyTableContext.addTable(newTableIndex, dataAfter.getName(), dataAfter.getClassifierNode(), writeContext.getMappingContext()); + classifyTableContext.addTable(newTableIndex, dataAfter.getName(), dataAfter.getClassifierNode(), + writeContext.getMappingContext()); LOG.debug("Successfully created classify table(id={]): iid={} dataAfter={}", newTableIndex, id, dataAfter); } catch (VppBaseCallException e) { throw new WriteFailedException.CreateFailedException(id, dataAfter, e); @@ -86,7 +88,7 @@ public class ClassifyTableWriter extends VppNodeWriter LOG.debug("Removing classify table: iid={} dataBefore={}", id, dataBefore); final String tableName = dataBefore.getName(); checkState(classifyTableContext.containsTable(tableName, writeContext.getMappingContext()), - "Removing classify table {}, but index could not be found in the classify table context", tableName); + "Removing classify table {}, but index could not be found in the classify table context", tableName); final int tableIndex = classifyTableContext.getTableIndex(tableName, writeContext.getMappingContext()); try { @@ -102,17 +104,17 @@ public class ClassifyTableWriter extends VppNodeWriter private int classifyAddDelTable(final boolean isAdd, @Nonnull final InstanceIdentifier id, @Nonnull final ClassifyTable table, final int tableId, final MappingContext ctx) - throws VppBaseCallException, WriteFailedException { + throws VppBaseCallException, WriteFailedException { final int missNextIndex = - getNodeIndex(table.getMissNext(), table, classifyTableContext, ctx, id); + getNodeIndex(table.getMissNext(), table, classifyTableContext, ctx, id); final CompletionStage createClassifyTableReplyCompletionStage = - getFutureJVpp() - .classifyAddDelTable(getClassifyAddDelTableRequest(isAdd, tableId, table, missNextIndex, ctx)); + getFutureJVpp() + .classifyAddDelTable(getClassifyAddDelTableRequest(isAdd, tableId, table, missNextIndex, ctx)); final ClassifyAddDelTableReply reply = - TranslateUtils.getReplyForWrite(createClassifyTableReplyCompletionStage.toCompletableFuture(), id); + getReplyForWrite(createClassifyTableReplyCompletionStage.toCompletableFuture(), id); return reply.newTableIndex; } -- cgit 1.2.3-korg